JdbcStringBasedCacheStore throws java.lang.ArrayIndexOutOfBoundsException when logging
that certain key type is unsupported and the key length is short
-------------------------------------------------------------------------------------------------------------------------------------------------------
Key: ISPN-1572
URL:
https://issues.jboss.org/browse/ISPN-1572
Project: Infinispan
Issue Type: Bug
Affects Versions: 5.1.0.BETA5
Reporter: Martin Gencur
Assignee: Galder ZamarreƱo
I tried to store key "key1" via HotRod client and the key was supposed to be
stored in a DB. However, I got this exception:
{code}
[java] 10:58:56,944 ERROR [org.infinispan.interceptors.InvocationContextInterceptor]
(HotRodServerWorker-1-1) ISPN000136: Execution error:
java.lang.ArrayIndexOutOfBoundsException: 5
[java] at org.infinispan.util.Util.toHexString(Util.java:437)
[infinispan-commons-5.1.0-SNAPSHOT.jar:]
[java] at org.infinispan.util.Util.printArray(Util.java:415)
[infinispan-commons-5.1.0-SNAPSHOT.jar:]
[java] at org.infinispan.util.ByteArrayKey.toString(ByteArrayKey.java:74)
[infinispan-commons-5.1.0-SNAPSHOT.jar:]
[java] at java.lang.String.valueOf(String.java:2826) [:1.6.0_21]
[java] at java.lang.StringBuilder.append(StringBuilder.java:115) [:1.6.0_21]
[java] at
org.infinispan.loaders.keymappers.UnsupportedKeyTypeException.<init>(UnsupportedKeyTypeException.java:38)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore.getLockFromKey(JdbcStringBasedCacheStore.java:195)
[java] at
org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore.getLockFromKey(JdbcStringBasedCacheStore.java:87)
[java] at
org.infinispan.loaders.LockSupportCacheStore.load(LockSupportCacheStore.java:127)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.CacheLoaderInterceptor.loadIfNeeded(CacheLoaderInterceptor.java:130)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.CacheLoaderInterceptor.visitPutKeyValueCommand(CacheLoaderInterceptor.java:79)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.ActivationInterceptor.visitPutKeyValueCommand(ActivationInterceptor.java:60)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.EntryWrappingInterceptor.invokeNextAndApplyChanges(EntryWrappingInterceptor.java:188)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.EntryWrappingInterceptor.visitPutKeyValueCommand(EntryWrappingInterceptor.java:137)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.locking.OptimisticLockingInterceptor.visitPutKeyValueCommand(OptimisticLockingInterceptor.java:108)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:133)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:61)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:214)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:152)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.CacheMgmtInterceptor.visitPutKeyValueCommand(CacheMgmtInterceptor.java:115)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:119)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:104)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:64)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:61)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:318)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.CacheImpl.executeCommandAndCommitIfNeeded(CacheImpl.java:917)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at org.infinispan.CacheImpl.put(CacheImpl.java:631)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at org.infinispan.CacheImpl.put(CacheImpl.java:623)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.AbstractDelegatingCache.put(AbstractDelegatingCache.java:114)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.server.core.AbstractProtocolDecoder.put(AbstractProtocolDecoder.scala:187)
[infinispan-server-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.server.core.AbstractProtocolDecoder.decodeValue(AbstractProtocolDecoder.scala:141)
[infinispan-server-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.server.core.AbstractProtocolDecoder.decode(AbstractProtocolDecoder.scala:71)
[infinispan-server-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.server.core.AbstractProtocolDecoder.decode(AbstractProtocolDecoder.scala:44)
[infinispan-server-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.jboss.netty.handler.codec.replay.CustomReplayingDecoder.callDecode(CustomReplayingDecoder.java:250)
[infinispan-server-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.jboss.netty.handler.codec.replay.CustomReplayingDecoder.messageReceived(CustomReplayingDecoder.java:223)
[infinispan-server-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.infinispan.server.core.AbstractProtocolDecoder.messageReceived(AbstractProtocolDecoder.scala:351)
[infinispan-server-core-5.1.0-SNAPSHOT.jar:]
[java] at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
[netty-3.2.5.Final.jar:]
[java] at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
[netty-3.2.5.Final.jar:]
[java] at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
[netty-3.2.5.Final.jar:]
[java] at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
[netty-3.2.5.Final.jar:]
[java] at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
[netty-3.2.5.Final.jar:]
[java] at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
[netty-3.2.5.Final.jar:]
[java] at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:280)
[netty-3.2.5.Final.jar:]
[java] at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:200)
[netty-3.2.5.Final.jar:]
[java] at
org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
[netty-3.2.5.Final.jar:]
[java] at
org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44)
[netty-3.2.5.Final.jar:]
[java] at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[:1.6.0_21]
[java] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[:1.6.0_21]
[java] at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]
{code}
After I extended the key to "keykeykey1" I got the following:
{code}
[java] 12:17:36,066 ERROR [org.infinispan.interceptors.InvocationContextInterceptor]
(MemcachedServerWorker-1-1) ISPN000136: Execution error:
org.infinispan.loaders.keymappers.UnsupportedKeyTypeException: Unsupported key type:
'org.infinispan.util.ByteArrayKey' on key: ByteArrayKey{data=ByteArray{size=13,
hashCode=6c1ef8f5, array=0x033e0a6b65796b65..}}
[java] at
org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore.getLockFromKey(JdbcStringBasedCacheStore.java:195)
[java] at
org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore.getLockFromKey(JdbcStringBasedCacheStore.java:87)
[java] at
org.infinispan.loaders.LockSupportCacheStore.load(LockSupportCacheStore.java:127)
[infinispan-core-5.1.0-SNAPSHOT.jar:]
....
{code}
IMO, this is caused by implementation of printArray and toHexString methods of
org.infinispan.util.Util class.
printArray() calls sb.append(toHexString(array, 8)); and toHexString does not check that
the number 8 is out of bounds of the array when the key name is short.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira