Skip to content

Commit 63dfc11

Browse files
committed
added unregister methods in MessagePack class
1 parent b2f06da commit 63dfc11

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/java/org/msgpack/MessagePack.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,18 @@ public <T> void register(Class<T> type, Template<T> tmpl) {
183183
registry.register(type, tmpl);
184184
}
185185

186+
public boolean unregister(Class<?> type) {
187+
return registry.unregister(type);
188+
}
189+
190+
public void unregister() {
191+
registry.unregister();
192+
}
193+
186194
public <T> Template<T> lookup(Class<T> type) {
187195
return registry.lookup(type);
188196
}
189197

190-
191198
private static final MessagePack globalMessagePack = new MessagePack();
192199

193200
@Deprecated

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.msgpack.template.StringTemplate;
4949
import org.msgpack.template.Template;
5050
import org.msgpack.template.ValueTemplate;
51-
import org.msgpack.template.builder.AbstractTemplateBuilder;
5251
import org.msgpack.template.builder.TemplateBuilder;
5352
import org.msgpack.template.builder.TemplateBuilderChain;
5453
import org.msgpack.type.Value;
@@ -144,12 +143,12 @@ public synchronized void registerGeneric(final Type targetType, final GenericTem
144143
}
145144
}
146145

147-
public boolean unregister(final Type targetType) {
146+
public synchronized boolean unregister(final Type targetType) {
148147
Template<Type> tmpl = cache.remove(targetType);
149148
return tmpl != null;
150149
}
151150

152-
public void unregister() {
151+
public synchronized void unregister() {
153152
cache.clear();
154153
}
155154

0 commit comments

Comments
 (0)