Skip to content

Commit

Permalink
Clear extRegistry.getClassCtx if generate serializer class failed
Browse files Browse the repository at this point in the history
  • Loading branch information
chaokunyang committed Dec 8, 2023
1 parent bd7e234 commit 3355cb9
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions java/fury-core/src/main/java/io/fury/resolver/ClassResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -951,35 +951,37 @@ private Class<? extends Serializer> getObjectSerializerClass(
// avoid potential recursive call for seq codec generation.
return LazyInitBeanSerializer.class;
} else {
extRegistry.getClassCtx.add(cls);
Class<? extends Serializer> sc;
switch (fury.getCompatibleMode()) {
case SCHEMA_CONSISTENT:
sc =
fury.getJITContext()
.registerSerializerJITCallback(
() -> ObjectSerializer.class,
() -> loadCodegenSerializer(fury, cls),
callback);
extRegistry.getClassCtx.remove(cls);
return sc;
case COMPATIBLE:
// If share class meta, compatible serializer won't be necessary, class
// definition will be sent to peer to create serializer for deserialization.
sc =
fury.getJITContext()
.registerSerializerJITCallback(
() -> shareMeta ? ObjectSerializer.class : CompatibleSerializer.class,
() ->
shareMeta
? loadCodegenSerializer(fury, cls)
: loadCompatibleCodegenSerializer(fury, cls),
callback);
extRegistry.getClassCtx.remove(cls);
return sc;
default:
throw new UnsupportedOperationException(
String.format("Unsupported mode %s", fury.getCompatibleMode()));
try {
extRegistry.getClassCtx.add(cls);
Class<? extends Serializer> sc;
switch (fury.getCompatibleMode()) {
case SCHEMA_CONSISTENT:
sc =
fury.getJITContext()
.registerSerializerJITCallback(
() -> ObjectSerializer.class,
() -> loadCodegenSerializer(fury, cls),
callback);
return sc;
case COMPATIBLE:
// If share class meta, compatible serializer won't be necessary, class
// definition will be sent to peer to create serializer for deserialization.
sc =
fury.getJITContext()
.registerSerializerJITCallback(
() -> shareMeta ? ObjectSerializer.class : CompatibleSerializer.class,
() ->
shareMeta
? loadCodegenSerializer(fury, cls)
: loadCompatibleCodegenSerializer(fury, cls),
callback);
return sc;
default:
throw new UnsupportedOperationException(
String.format("Unsupported mode %s", fury.getCompatibleMode()));
}
} finally {
extRegistry.getClassCtx.remove(cls);
}
}
} else {
Expand Down

0 comments on commit 3355cb9

Please sign in to comment.