@Override
    public AbstractByteBuf encode(final Object object, final Map<String, String> context) throws SofaRpcException {
        if (object == null) {
            throw buildSerializeError("Unsupported null message!");
        }
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            fury.setClassLoader(contextClassLoader);
            CustomSerializer customSerializer = getObjCustomSerializer(object);
            if (customSerializer != null) {
                return customSerializer.encodeObject(object, context);
            } else {
                MemoryBuffer writeBuffer = MemoryBuffer.newHeapBuffer(32);
                writeBuffer.writerIndex(0);
                fury.serialize(writeBuffer, object);
                return new ByteArrayWrapperByteBuf(writeBuffer.getBytes(0, writeBuffer.writerIndex()));
            }
        } catch (Exception e) {
            throw buildSerializeError(e.getMessage(), e);
        } finally {
            fury.clearClassLoader(contextClassLoader);
        }
    }
@Test
    public void testChecker() throws Exception {
        // default fury checkMode is STRICT
        WhiteClassHasBlackClass whiteClassNullBlackClass = new WhiteClassHasBlackClass();
        NoneClassHasBlackClass noneClassNullBlackClass = new NoneClassHasBlackClass();

        BlackListClass blackListClass = new BlackListClass();
        WhiteClassHasBlackClass whiteClassHasBlackClass = new WhiteClassHasBlackClass();
        whiteClassHasBlackClass.setBlackListClass(blackListClass);
        NoneClassHasBlackClass noneClassHasBlackClass = new NoneClassHasBlackClass();
        noneClassHasBlackClass.setBlackListClass(blackListClass);

        try {
            serializer.encode(noneClassNullBlackClass, null);
            Assert.fail();
        } catch (Exception e) {

        }

        try {
            serializer.encode(noneClassHasBlackClass, null);
            Assert.fail();
        } catch (Exception e) {

        }

        try {
            serializer.encode(blackListClass, null);
            Assert.fail();
        } catch (Exception e) {

        }

        serializer.encode(whiteClassNullBlackClass, null);
        try {
            serializer.encode(whiteClassHasBlackClass, null);
            Assert.fail();
        } catch (Exception e) {

        }

        // test change fury checkMode to blacklist
        System.getProperties().put("sofa.rpc.codec.serialize.checkMode", "WARN");
        FurySerializer furySerializer = new FurySerializer();

        furySerializer.encode(noneClassNullBlackClass, null);

        try {
            furySerializer.encode(noneClassHasBlackClass, null);
            Assert.fail();
        } catch (Exception e) {

        }

        try {
            //Not registered this class
            furySerializer.encode(blackListClass, null);
            Assert.fail();
        } catch (Exception e) {

        }

        furySerializer.encode(whiteClassNullBlackClass, null);
        try {
            furySerializer.encode(whiteClassHasBlackClass, null);
            Assert.fail();
        } catch (Exception e) {

        }
        System.getProperties().remove("sofa.rpc.codec.serialize.checkMode");

        // test change fury checkMode to none
        System.getProperties().put("sofa.rpc.codec.serialize.checkMode", "DISABLE");
        FurySerializer noneFurySerializer = new FurySerializer();
        noneFurySerializer.encode(noneClassNullBlackClass, null);
        noneFurySerializer.encode(noneClassHasBlackClass, null);
        noneFurySerializer.encode(blackListClass, null);
        noneFurySerializer.encode(whiteClassNullBlackClass, null);
        noneFurySerializer.encode(whiteClassHasBlackClass, null);
        System.getProperties().remove("sofa.rpc.codec.serialize.checkMode");
    }