Skip to content

Commit

Permalink
metaspace内存持续上涨 (#3299)
Browse files Browse the repository at this point in the history
* metaspace内存持续上涨

* 重复加载testcase

* Update ObjectWriterProviderTest.java
  • Loading branch information
LSL-cloud authored Jan 22, 2025
1 parent 2978489 commit a15a7fc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ private ObjectWriter getObjectWriterInternal(Type objectType, Class objectClass,
if (objectWriter != null) {
return objectWriter;
}
} else {
objectWriter = cache.get(objectType);
if (objectWriter != null) {
return objectWriter;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import com.alibaba.fastjson2.writer.ObjectWriter;
import com.alibaba.fastjson2.writer.ObjectWriterProvider;
import org.junit.jupiter.api.Test;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assertions.*;

Expand Down Expand Up @@ -131,9 +136,28 @@ public void testWriter2() {
assertSame(writer1, JSON.registerIfAbsent(Bean.class, writer, false));
}

@Test
public void testWriterProxy() throws InterruptedException {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Bean.class);
enhancer.setCallback(new BeanMethodInterceptor());
Object proxy1 = enhancer.create();
JSON.toJSONString(proxy1);
JSON.toJSONString(proxy1);
TimeUnit.MINUTES.sleep(60);
}

public static class Bean {
}

public static class BeanMethodInterceptor implements MethodInterceptor {

@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
return methodProxy.invokeSuper(o, objects);
}
}

public static class BeanWriter
implements ObjectWriter {
@Override
Expand Down

0 comments on commit a15a7fc

Please sign in to comment.