public static <T> T copyWithGson(Object orig, Class<T> c) {
        // Backup the current MetaContext before assigning a new one.
        MetaContext oldContext = MetaContext.get();
        MetaContext metaContext = new MetaContext();
        metaContext.setStarRocksMetaVersion(FeConstants.STARROCKS_META_VERSION);
        metaContext.setThreadLocalInfo();
        try {
            String origJsonStr = GsonUtils.GSON.toJson(orig);
            return GsonUtils.GSON.fromJson(origJsonStr, c);
        } catch (Exception e) {
            LOG.warn("failed to copy object.", e);
            return null;
        } finally {
            // Restore the old MetaContext.
            if (oldContext != null) {
                oldContext.setThreadLocalInfo();
            } else {
                MetaContext.remove();
            }
        }
    }
@Test
    public void testCopyWithJson() {
        GsonSerializationTest.OrigClassA classA = new GsonSerializationTest.OrigClassA(1);
        GsonSerializationTest.OrigClassA copied = DeepCopy.copyWithGson(classA, GsonSerializationTest.OrigClassA.class);
        Assert.assertTrue(copied != null);
        Assert.assertEquals(classA.flag, copied.flag);
        Assert.assertEquals(classA.classA1.flag, copied.classA1.flag);
    }