Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
JCR Resource 2.2.8
-
None
Description
When trying to serialize a byte[] in Sling Job properties Map I noticed that an error occurs when using the JCR Resource Resolver caused by a ClassCastException in JcrPropertyMapCacheEntry since it tries to cast a byte to Object. This therefore doesn't happen when serializing Byte[].
This also happens when trying to serialize long/int/...[] due to the same cast.
Here's the stacktrace:
could not add an item to the queue java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
at org.apache.sling.jcr.resource.internal.helper.JcrPropertyMapCacheEntry.<init>(JcrPropertyMapCacheEntry.java:94)
at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:630)
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.create(JcrResourceProvider.java:453)
at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.create(ResourceResolverImpl.java:1076)
at org.apache.sling.api.resource.ResourceUtil.getOrCreateResource(ResourceUtil.java:578)
at org.apache.sling.event.impl.support.ResourceHelper.getOrCreateResource(ResourceHelper.java:221)
at org.apache.sling.event.impl.jobs.JobManagerImpl.writeJob(JobManagerImpl.java:1323)
at org.apache.sling.event.impl.jobs.JobManagerImpl.addJobInteral(JobManagerImpl.java:1242)
at org.apache.sling.event.impl.jobs.JobManagerImpl.addJob(JobManagerImpl.java:794)
Here's the code snippet that triggers the error:
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("BIN","a string".getBytes());
Job job = jobManager.addJob("name", "id", properties);
See testcase below to reproduce the problem on the JCR Resource Resolver:
package org.apache.sling.jcr.resource.internal.helper;
import org.junit.Test;
public class JcrPropertyMapCacheEntryTest {
@Test
public void testByteArray() throws Exception
@Test
public void testLongArray() throws Exception
}