Skip to content

Commit 3d9ef8b

Browse files
authored
Merge pull request #110 from alibaba/develop-for-20181027
Develop for 20181027
2 parents 5414ec5 + b4e2e06 commit 3d9ef8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1338
-154
lines changed

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: generic
2+
3+
jdk:
4+
- openjdk6
5+
- oraclejdk6
6+
7+
cache:
8+
directories:
9+
- "$HOME/.m2/repository"
10+
11+
script:
12+
- cd bin
13+
- ./sandbox-packages.sh
14+
- cd ..
15+
16+
after_success:
17+
- bash <(curl -s https://codecov.io/bash)

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
## ![BANNER](https://github.com/alibaba/jvm-sandbox/wiki/img/BANNER.png)
2+
3+
[![Build Status](https://travis-ci.org/alibaba/jvm-sandbox.svg?branch=develop-for-20181027)](https://travis-ci.org/alibaba/jvm-sandbox)
4+
[![codecov](https://codecov.io/gh/alibaba/jvm-sandbox/branch/develop-for-20181027/graph/badge.svg)](https://codecov.io/gh/alibaba/jvm-sandbox)
5+
![license](https://img.shields.io/github/license/alibaba/arthas.svg)
6+
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/alibaba/jvm-sandbox.svg)](http://isitmaintained.com/project/alibaba/jvm-sandbox "Average time to resolve an issue")
7+
[![Percentage of issues still open](http://isitmaintained.com/badge/open/alibaba/jvm-sandbox.svg)](http://isitmaintained.com/project/alibaba/jvm-sandbox "Percentage of issues still open")
8+
29
> JVM沙箱容器,一种JVM的非侵入式运行期AOP解决方案<br/>
310
> Real - time non-invasive AOP framework container based on JVM
411

bin/sandbox-packages.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exit_on_err()
1414
}
1515

1616
# maven package the sandbox
17-
mvn clean package -Dmaven.test.skip=false -f ../pom.xml \
17+
mvn clean cobertura:cobertura package -Dmaven.test.skip=false -f ../pom.xml \
1818
|| exit_on_err 1 "package sandbox failed."
1919

2020
# reset the target dir

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
<groupId>com.alibaba.jvm.sandbox</groupId>
66
<artifactId>sandbox</artifactId>
7-
<version>1.1.0</version>
7+
<version>1.1.1-SNAPSHOT</version>
88
<packaging>pom</packaging>
99

1010
<name>sandbox ${sandbox.version}</name>
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<sandbox.version>1.1.0</sandbox.version>
14+
<sandbox.version>1.1.1-SNAPSHOT</sandbox.version>
1515
</properties>
1616

1717
<build>

sandbox-agent/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alibaba.jvm.sandbox</groupId>
88
<artifactId>sandbox</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.1.1-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>sandbox-agent</artifactId>
1212
<name>sandbox-agent ${sandbox.version}</name>

sandbox-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alibaba.jvm.sandbox</groupId>
88
<artifactId>sandbox</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.1.1-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>sandbox-api</artifactId>
1212
<name>sandbox-api ${sandbox.version}</name>

sandbox-common-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>sandbox</artifactId>
88
<groupId>com.alibaba.jvm.sandbox</groupId>
9-
<version>1.1.0</version>
9+
<version>1.1.1-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>sandbox-common-api</artifactId>
1212
<name>sandbox-common-api ${sandbox.version}</name>

sandbox-core/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alibaba.jvm.sandbox</groupId>
88
<artifactId>sandbox</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.1.1-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>sandbox-core</artifactId>
1212
<name>sandbox-core ${sandbox.version}</name>
@@ -134,17 +134,17 @@
134134
<dependency>
135135
<groupId>org.ow2.asm</groupId>
136136
<artifactId>asm</artifactId>
137-
<version>6.0</version>
137+
<version>7.0</version>
138138
</dependency>
139139
<dependency>
140140
<groupId>org.ow2.asm</groupId>
141141
<artifactId>asm-commons</artifactId>
142-
<version>6.0</version>
142+
<version>7.0</version>
143143
</dependency>
144144
<dependency>
145145
<groupId>org.ow2.asm</groupId>
146146
<artifactId>asm-util</artifactId>
147-
<version>6.0</version>
147+
<version>7.0</version>
148148
</dependency>
149149
<dependency>
150150
<groupId>org.apache.commons</groupId>

sandbox-core/src/main/java/com/alibaba/jvm/sandbox/core/enhance/EventEnhancer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static org.objectweb.asm.ClassReader.EXPAND_FRAMES;
1818
import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES;
1919
import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS;
20+
import static org.objectweb.asm.Opcodes.ASM7;
2021

2122
/**
2223
* 事件代码增强器
@@ -90,7 +91,7 @@ private byte[] weavingEvent(final ClassLoader targetClassLoader,
9091
final int targetClassLoaderObjectID = ObjectIDs.instance.identity(targetClassLoader);
9192
cr.accept(
9293
new EventWeaver(
93-
Opcodes.ASM6, cw, namespace, listenerId,
94+
ASM7, cw, namespace, listenerId,
9495
targetClassLoaderObjectID,
9596
cr.getClassName(),
9697
signCodes,

sandbox-core/src/main/java/com/alibaba/jvm/sandbox/core/enhance/weaver/asm/ReWriteMethod.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ReWriteMethod extends AdviceAdapter implements Opcodes, AsmTypes, A
1818
* Creates a new {@link AdviceAdapter}.
1919
*
2020
* @param api the ASM API version implemented by this visitor. Must be one
21-
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM6}.
21+
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM7}.
2222
* @param mv the method visitor to which this adapter delegates calls.
2323
* @param access the method's access flags (see {@link Opcodes}).
2424
* @param name the method's name.

sandbox-core/src/main/java/com/alibaba/jvm/sandbox/core/server/jetty/JettyCoreServer.java

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public boolean isBind() {
6969
@Override
7070
public void unbind() throws IOException {
7171
try {
72+
7273
initializer.destroyProcess(new Initializer.Processor() {
7374
@Override
7475
public void process() throws Throwable {
@@ -86,6 +87,10 @@ public void process() throws Throwable {
8687
httpServer.destroy();
8788
logger.info("{} was destroyed.", this);
8889

90+
// 关闭对象池
91+
EventListenerHandlers.getSingleton().getEventPool().close();
92+
logger.info("{} was closed the Event-Pool!", this);
93+
8994
} catch (Throwable cause) {
9095
logger.warn("{} unBind failed.", this, cause);
9196
throw new IOException("unBind failed.", cause);

sandbox-core/src/main/java/com/alibaba/jvm/sandbox/core/util/EventPool.java

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ public EventPool() {
2828
this.isEnable = this.pool != null;
2929
}
3030

31+
/**
32+
* 关闭并清理对象池
33+
* <p>
34+
* 修复问题:#108
35+
* </p>
36+
*/
37+
public void close() {
38+
if (null != pool) {
39+
pool.close();
40+
}
41+
}
42+
3143
private KeyedObjectPool<Event.Type, Event> createEventPool() {
3244
final CoreConfigure cfg = CoreConfigure.getInstance();
3345
if (cfg.isEventPoolEnable()) {

sandbox-core/src/main/java/com/alibaba/jvm/sandbox/core/util/matcher/structure/BehaviorStructure.java

+24-23
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,6 @@ public class BehaviorStructure extends MemberStructure {
2828
private final List<ClassStructure> exceptionTypeClassStructures;
2929
private final List<ClassStructure> annotationTypeClassStructures;
3030

31-
private final LazyGet<String> signCodeLazyGet = new LazyGet<String>() {
32-
@Override
33-
protected String initialValue() {
34-
return String.format("%s#%s(%s)",
35-
getDeclaringClassStructure().getJavaClassName(),
36-
getName(),
37-
join(takeJavaClassNames(getParameterTypeClassStructures()), ",")
38-
);
39-
}
40-
};
41-
42-
private final LazyGet<String> toStringLazyGet = new LazyGet<String>() {
43-
@Override
44-
protected String initialValue() {
45-
return String.format("%s:[%s]:%s:%s",
46-
getReturnTypeClassStructure().getJavaClassName(),
47-
join(takeJavaClassNames(getAnnotationTypeClassStructures()), ","),
48-
getSignCode(),
49-
join(takeJavaClassNames(getExceptionTypeClassStructures()), ",")
50-
);
51-
}
52-
};
53-
5431
BehaviorStructure(final Access access,
5532
final String name,
5633
final ClassStructure declaringClassStructure,
@@ -109,6 +86,18 @@ private Collection<String> takeJavaClassNames(final Collection<ClassStructure> c
10986
return javaClassNames;
11087
}
11188

89+
90+
private final LazyGet<String> signCodeLazyGet = new LazyGet<String>() {
91+
@Override
92+
protected String initialValue() {
93+
return String.format("%s#%s(%s)",
94+
getDeclaringClassStructure().getJavaClassName(),
95+
getName(),
96+
join(takeJavaClassNames(getParameterTypeClassStructures()), ",")
97+
);
98+
}
99+
};
100+
112101
/**
113102
* 获取行为签名
114103
* <p>
@@ -121,6 +110,18 @@ public String getSignCode() {
121110
return signCodeLazyGet.get();
122111
}
123112

113+
private final LazyGet<String> toStringLazyGet = new LazyGet<String>() {
114+
@Override
115+
protected String initialValue() {
116+
return String.format("%s:[%s]:%s:%s",
117+
getReturnTypeClassStructure().getJavaClassName(),
118+
join(takeJavaClassNames(getAnnotationTypeClassStructures()), ","),
119+
getSignCode(),
120+
join(takeJavaClassNames(getExceptionTypeClassStructures()), ",")
121+
);
122+
}
123+
};
124+
124125
@Override
125126
public String toString() {
126127
// %s[0] : return-type

0 commit comments

Comments
 (0)