sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (SLING-3140) ClassCastException while serializing byte[] in Sling Job with JCR Resource Resolver
Date Tue, 01 Oct 2013 16:05:25 GMT

     [ https://issues.apache.org/jira/browse/SLING-3140?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Carsten Ziegeler reassigned SLING-3140:
---------------------------------------

    Assignee: Carsten Ziegeler

> ClassCastException while serializing byte[] in Sling Job with JCR Resource Resolver
> -----------------------------------------------------------------------------------
>
>                 Key: SLING-3140
>                 URL: https://issues.apache.org/jira/browse/SLING-3140
>             Project: Sling
>          Issue Type: Bug
>          Components: JCR
>    Affects Versions: JCR Resource 2.2.8
>            Reporter: Tommaso Teofili
>            Assignee: Carsten Ziegeler
>             Fix For: JCR Resource 2.3.0
>
>
> 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 {
>     Byte[] ba = new Byte[0];
>     new JcrPropertyMapCacheEntry(ba, null);
>     // ok
>     byte[] ba2 = new byte[0];
>     new JcrPropertyMapCacheEntry(ba2, null);
>     // fail
>   }
>   @Test
>   public void testLongArray() throws Exception {
>     Long[] ba = new Long[0];
>     new JcrPropertyMapCacheEntry(ba, null);
>     // ok
>     long[] ba2 = new long[0];
>     new JcrPropertyMapCacheEntry(ba2, null);
>     // fail
>   }
> }



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message