Skip to content

Commit 85b455f

Browse files
committed
fixed bug: validation error occurs when loading templates of array classes with JavassistTemplateBuilder
1 parent 2eaa5b6 commit 85b455f

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/main/java/org/msgpack/template/TemplateRegistry.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,8 @@ private <T> Template<T> lookupAfterBuilding(Class<T> targetClass) {
301301
TemplateBuilder builder = chain.select(targetClass, true);
302302
Template<T> tmpl = null;
303303
if (builder != null) {
304-
if (builder instanceof ArrayTemplateBuilder) {
305-
tmpl = builder.loadTemplate(targetClass);
306-
} else {
307-
// TODO #MN for Android, we should modify here
308-
tmpl = chain.getForceBuilder().loadTemplate(targetClass);
309-
}
304+
// TODO #MN for Android, we should modify here
305+
tmpl = chain.getForceBuilder().loadTemplate(targetClass);
310306
if (tmpl != null) {
311307
register(targetClass, tmpl);
312308
return tmpl;

src/main/java/org/msgpack/template/builder/JavassistTemplateBuilder.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,16 @@ public <T> Template<T> loadTemplate(Type targetType) {
150150
// FIXME #MN must consider how to load "reference cycle class" in next
151151
// version
152152
Class<T> targetClass = (Class) targetType;
153-
checkClassValidation(targetClass);
153+
//checkClassValidation(targetClass);
154154
try {
155155
// check loadable
156156
String tmplName = targetClass.getName() + "_$$_Template";
157-
targetClass.getClassLoader().loadClass(tmplName);
157+
ClassLoader cl = targetClass.getClassLoader();
158+
if (cl != null) {
159+
cl.loadClass(tmplName);
160+
} else {
161+
return null;
162+
}
158163
} catch (ClassNotFoundException e) {
159164
return null;
160165
}

src/test/java/org/msgpack/TestSimpleArrays.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import org.msgpack.unpacker.BufferUnpacker;
1818
import org.msgpack.unpacker.Converter;
1919

20-
21-
@Ignore
2220
public class TestSimpleArrays {
2321

2422
@Message
@@ -204,7 +202,7 @@ public GenericsTest() {
204202
}
205203

206204
@SuppressWarnings({ "unchecked", "rawtypes" })
207-
@Test
205+
@Ignore @Test
208206
public void testGenerics() throws Exception {
209207
MessagePack msgpack = new MessagePack();
210208

@@ -272,7 +270,7 @@ public Dim2Test() {
272270
}
273271

274272
@SuppressWarnings({ "unchecked", "rawtypes" })
275-
@Test
273+
@Ignore @Test
276274
public void testDim2() throws Exception {
277275
MessagePack msgpack = new MessagePack();
278276
Dim2Test t = new Dim2Test();
@@ -337,7 +335,7 @@ public Dim3Test() {
337335
}
338336

339337
@SuppressWarnings({ "unchecked", "rawtypes" })
340-
@Test
338+
@Ignore @Test
341339
public void testDim3() throws Exception {
342340
MessagePack msgpack = new MessagePack();
343341

0 commit comments

Comments
 (0)