Optional.get() cannot be called on an absent value"
Occasionally, the following error occurs when performing an update. Sometimes there are no errors, why?
nested exception is org.apache.ibatis.exceptions.PersistenceException: \n### Error updating database. Cause: java.lang.IllegalStateException: Optional.get() cannot be called on an absent value\n### The error may involve defaultParameterMap\n### The error occurred while setting parameters\n### SQL: update ic_test SET locked_num=locked_num + ?, update_time=now(), version = version + 1, update_person = ?, normal_locked_num=normal_locked_num + ? where 1=1 and inventory_num >= locked_num + ? and normal_inventory_num >= normal_locked_num + ? AND sku_code=? AND warehouse_code=? AND first_channel=? AND second_channel=? AND is_deleted = 0 \n### Cause: java.lang.IllegalStateException: Optional.get() cannot be called on an absent value",
I can't understand. Can you make title and description more clear?
Execute the above SQL report the following error, what is the general reason?
Caused by: java.lang.IllegalStateException: Optional.get() cannot be called on an absent value at com.google.common.base.Absent.get(Absent.java:45) at org.apache.shardingsphere.core.parsing.antlr.filler.sharding.statement.impl.dml.UpdateSetWhereFiller.fill(UpdateSetWhereFiller.java:49) at org.apache.shardingsphere.core.parsing.antlr.filler.sharding.statement.impl.dml.UpdateSetWhereFiller.fill(UpdateSetWhereFiller.java:39) at org.apache.shardingsphere.core.parsing.antlr.filler.SQLStatementFillerEngine.fill(SQLStatementFillerEngine.java:82) at org.apache.shardingsphere.core.parsing.antlr.AntlrParsingEngine.parse(AntlrParsingEngine.java:71) at org.apache.shardingsphere.core.parsing.SQLParsingEngine.parse(SQLParsingEngine.java:62) at org.apache.shardingsphere.core.routing.router.sharding.ParsingSQLRouter.parse(ParsingSQLRouter.java:86) at org.apache.shardingsphere.core.routing.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:64) at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.sqlRoute(ShardingPreparedStatement.java:222) at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:168) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) at com.sun.proxy.$Proxy112.execute(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46) at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ... 70 common frames omitted
Version conflict
Determine which library you are using Java or Guava, they don't behave the same with Optional get()
- went thru all sorts of exclusions
- in the end, we are using guava Optionals not Java
- guava optional.get() requires the value is present
- with guava use orNull() not get()
- see: https://www.tutorialspoint.com/guava/guava_optional_class.htm
- String url = currentConfig.getProperty("db." + db + ".url").orNull(); // .get() fails with absent value
- java optional.get()
- If a value is present in this Optional, returns the value, otherwise throws NoSuchElementException.