void cleanCurrentEntryInLocal() {
        if (context instanceof NullContext) {
            return;
        }
        Context originalContext = context;
        if (originalContext != null) {
            Entry curEntry = originalContext.getCurEntry();
            if (curEntry == this) {
                Entry parent = this.parent;
                originalContext.setCurEntry(parent);
                if (parent != null) {
                    ((CtEntry)parent).child = null;
                }
            } else {
                String curEntryName = curEntry == null ? "none"
                    : curEntry.resourceWrapper.getName() + "@" + curEntry.hashCode();
                String msg = String.format("Bad async context state, expected entry: %s, but actual: %s",
                    getResourceWrapper().getName() + "@" + hashCode(), curEntryName);
                throw new IllegalStateException(msg);
            }
        }
    }
@Test
    public void testCleanCurrentEntryInLocal() {
        final String contextName = "abc";
        try {
            ContextUtil.enter(contextName);
            Context curContext = ContextUtil.getContext();
            Entry previousEntry = new CtEntry(new StringResourceWrapper("entry-sync", EntryType.IN),
                null, curContext);
            AsyncEntry entry = new AsyncEntry(new StringResourceWrapper("testCleanCurrentEntryInLocal", EntryType.OUT),
                null, curContext);

            assertSame(entry, curContext.getCurEntry());

            entry.cleanCurrentEntryInLocal();
            assertNotSame(entry, curContext.getCurEntry());
            assertSame(previousEntry, curContext.getCurEntry());
        } finally {
            ContextTestUtil.cleanUpContext();
        }
    }