IGNITE-141 - Marshallers refactoring
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f045a57d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f045a57d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f045a57d Branch: refs/heads/ignite-141 Commit: f045a57dc84a17093819cfae0d71f7754eeff295 Parents: 151e2c3 Author: Valentin Kulichenko <vkuliche...@gridgain.com> Authored: Mon Mar 2 15:49:48 2015 -0800 Committer: Valentin Kulichenko <vkuliche...@gridgain.com> Committed: Mon Mar 2 15:49:48 2015 -0800 ---------------------------------------------------------------------- .../ignite/internal/MarshallerContextImpl.java | 57 +++----------------- 1 file changed, 8 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f045a57d/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java index 86ebfd1..db8d7fb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java @@ -101,16 +101,16 @@ public class MarshallerContextImpl implements MarshallerContext { U.awaitQuiet(latch); if (clsById.putIfAbsent(id, F.t(cls, false)) == null) { - // TODO: IGNITE-141 - Do not create thread. - Thread t = new Thread(new MarshallerCacheUpdater(cache, id, cls.getName())); - - t.start(); - try { - t.join(); + String old = cache.putIfAbsent(id, cls.getName()); + + if (old != null && !old.equals(cls.getName())) + throw new IgniteException("Type ID collision occurred in OptimizedMarshaller. Use " + + "OptimizedMarshallerIdMapper to resolve it [id=" + id + ", clsName1=" + cls.getName() + + "clsName2=" + old + ']'); } - catch (InterruptedException e) { - throw new IgniteException(e); + catch (IgniteCheckedException e) { + throw U.convertException(e); } } } @@ -144,45 +144,4 @@ public class MarshallerContextImpl implements MarshallerContext { return t.get1(); } - - /** - */ - private static class MarshallerCacheUpdater implements Runnable { - /** */ - private final GridCacheAdapter<Integer, String> cache; - - /** */ - private final int typeId; - - /** */ - private final String clsName; - - /** - * @param cache Cache. - * @param typeId Type ID. - * @param clsName Class name. - */ - private MarshallerCacheUpdater(GridCacheAdapter<Integer, String> cache, int typeId, String clsName) { - assert cache != null; - - this.cache = cache; - this.typeId = typeId; - this.clsName = clsName; - } - - /** {@inheritDoc} */ - @Override public void run() { - try { - String old = cache.putIfAbsent(typeId, clsName); - - if (old != null && !old.equals(clsName)) - throw new IgniteException("Type ID collision acquired in OptimizedMarshaller. Use " + - "OptimizedMarshallerIdMapper to resolve it [id=" + typeId + ", clsName1=" + clsName + - "clsName2=" + old + ']'); - } - catch (IgniteCheckedException e) { - throw U.convertException(e); - } - } - } }