Skip to content

Commit

Permalink
Merge pull request #110 from alibaba/develop-for-20181027
Browse files Browse the repository at this point in the history
Develop for 20181027
  • Loading branch information
dongchenxu authored Nov 8, 2018
2 parents 5414ec5 + b4e2e06 commit 3d9ef8b
Show file tree
Hide file tree
Showing 47 changed files with 1,338 additions and 154 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: generic

jdk:
- openjdk6
- oraclejdk6

cache:
directories:
- "$HOME/.m2/repository"

script:
- cd bin
- ./sandbox-packages.sh
- cd ..

after_success:
- bash <(curl -s https://codecov.io/bash)
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## ![BANNER](https://github.com/alibaba/jvm-sandbox/wiki/img/BANNER.png)

[![Build Status](https://travis-ci.org/alibaba/jvm-sandbox.svg?branch=develop-for-20181027)](https://travis-ci.org/alibaba/jvm-sandbox)
[![codecov](https://codecov.io/gh/alibaba/jvm-sandbox/branch/develop-for-20181027/graph/badge.svg)](https://codecov.io/gh/alibaba/jvm-sandbox)
![license](https://img.shields.io/github/license/alibaba/arthas.svg)
[![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")
[![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")

> JVM沙箱容器,一种JVM的非侵入式运行期AOP解决方案<br/>
> Real - time non-invasive AOP framework container based on JVM
Expand Down
2 changes: 1 addition & 1 deletion bin/sandbox-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exit_on_err()
}

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

# reset the target dir
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox</artifactId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
<packaging>pom</packaging>

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

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sandbox.version>1.1.0</sandbox.version>
<sandbox.version>1.1.1-SNAPSHOT</sandbox.version>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion sandbox-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox</artifactId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<artifactId>sandbox-agent</artifactId>
<name>sandbox-agent ${sandbox.version}</name>
Expand Down
2 changes: 1 addition & 1 deletion sandbox-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox</artifactId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<artifactId>sandbox-api</artifactId>
<name>sandbox-api ${sandbox.version}</name>
Expand Down
2 changes: 1 addition & 1 deletion sandbox-common-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>sandbox</artifactId>
<groupId>com.alibaba.jvm.sandbox</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<artifactId>sandbox-common-api</artifactId>
<name>sandbox-common-api ${sandbox.version}</name>
Expand Down
8 changes: 4 additions & 4 deletions sandbox-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox</artifactId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<artifactId>sandbox-core</artifactId>
<name>sandbox-core ${sandbox.version}</name>
Expand Down Expand Up @@ -134,17 +134,17 @@
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.0</version>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>6.0</version>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>6.0</version>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.objectweb.asm.ClassReader.EXPAND_FRAMES;
import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES;
import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS;
import static org.objectweb.asm.Opcodes.ASM7;

/**
* 事件代码增强器
Expand Down Expand Up @@ -90,7 +91,7 @@ private byte[] weavingEvent(final ClassLoader targetClassLoader,
final int targetClassLoaderObjectID = ObjectIDs.instance.identity(targetClassLoader);
cr.accept(
new EventWeaver(
Opcodes.ASM6, cw, namespace, listenerId,
ASM7, cw, namespace, listenerId,
targetClassLoaderObjectID,
cr.getClassName(),
signCodes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ReWriteMethod extends AdviceAdapter implements Opcodes, AsmTypes, A
* Creates a new {@link AdviceAdapter}.
*
* @param api the ASM API version implemented by this visitor. Must be one
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM6}.
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM7}.
* @param mv the method visitor to which this adapter delegates calls.
* @param access the method's access flags (see {@link Opcodes}).
* @param name the method's name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public boolean isBind() {
@Override
public void unbind() throws IOException {
try {

initializer.destroyProcess(new Initializer.Processor() {
@Override
public void process() throws Throwable {
Expand All @@ -86,6 +87,10 @@ public void process() throws Throwable {
httpServer.destroy();
logger.info("{} was destroyed.", this);

// 关闭对象池
EventListenerHandlers.getSingleton().getEventPool().close();
logger.info("{} was closed the Event-Pool!", this);

} catch (Throwable cause) {
logger.warn("{} unBind failed.", this, cause);
throw new IOException("unBind failed.", cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public EventPool() {
this.isEnable = this.pool != null;
}

/**
* 关闭并清理对象池
* <p>
* 修复问题:#108
* </p>
*/
public void close() {
if (null != pool) {
pool.close();
}
}

private KeyedObjectPool<Event.Type, Event> createEventPool() {
final CoreConfigure cfg = CoreConfigure.getInstance();
if (cfg.isEventPoolEnable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,6 @@ public class BehaviorStructure extends MemberStructure {
private final List<ClassStructure> exceptionTypeClassStructures;
private final List<ClassStructure> annotationTypeClassStructures;

private final LazyGet<String> signCodeLazyGet = new LazyGet<String>() {
@Override
protected String initialValue() {
return String.format("%s#%s(%s)",
getDeclaringClassStructure().getJavaClassName(),
getName(),
join(takeJavaClassNames(getParameterTypeClassStructures()), ",")
);
}
};

private final LazyGet<String> toStringLazyGet = new LazyGet<String>() {
@Override
protected String initialValue() {
return String.format("%s:[%s]:%s:%s",
getReturnTypeClassStructure().getJavaClassName(),
join(takeJavaClassNames(getAnnotationTypeClassStructures()), ","),
getSignCode(),
join(takeJavaClassNames(getExceptionTypeClassStructures()), ",")
);
}
};

BehaviorStructure(final Access access,
final String name,
final ClassStructure declaringClassStructure,
Expand Down Expand Up @@ -109,6 +86,18 @@ private Collection<String> takeJavaClassNames(final Collection<ClassStructure> c
return javaClassNames;
}


private final LazyGet<String> signCodeLazyGet = new LazyGet<String>() {
@Override
protected String initialValue() {
return String.format("%s#%s(%s)",
getDeclaringClassStructure().getJavaClassName(),
getName(),
join(takeJavaClassNames(getParameterTypeClassStructures()), ",")
);
}
};

/**
* 获取行为签名
* <p>
Expand All @@ -121,6 +110,18 @@ public String getSignCode() {
return signCodeLazyGet.get();
}

private final LazyGet<String> toStringLazyGet = new LazyGet<String>() {
@Override
protected String initialValue() {
return String.format("%s:[%s]:%s:%s",
getReturnTypeClassStructure().getJavaClassName(),
join(takeJavaClassNames(getAnnotationTypeClassStructures()), ","),
getSignCode(),
join(takeJavaClassNames(getExceptionTypeClassStructures()), ",")
);
}
};

@Override
public String toString() {
// %s[0] : return-type
Expand Down
Loading

0 comments on commit 3d9ef8b

Please sign in to comment.