Skip to content

Commit

Permalink
解决ClassLoader为null时造成的无法工作问题
Browse files Browse the repository at this point in the history
  • Loading branch information
manlge committed Aug 25, 2013
1 parent 2aeff1f commit dc4badb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/taobao/profile/config/ProfConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ private void loadConfig(Properties properties) throws VariableNotFoundException
String ignoreGetSetMethod = properties.getProperty("ignoreGetSetMethod");
String excludeClassLoader = properties.getProperty("excludeClassLoader");
String debugMode = properties.getProperty("debugMode");
String port = properties.getProperty("port");
setPort(port == null ? 50000 : Integer.valueOf(port));
setDebugMode("true".equals(debugMode));
String port = properties.getProperty("port");
setPort(port == null ? 50000 : Integer.valueOf(port));
setDebugMode("true".equalsIgnoreCase(debugMode == null ? null : debugMode.trim()));
setExcludeClassLoader(excludeClassLoader);
setExcludePackageStartsWith(excludePackageStartsWith);
setEndProfTime(endProfTime);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/taobao/profile/config/ProfFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class ProfFilter {

static {
// 默认不注入的Package
excludePackage.add("java");// 包含javax
excludePackage.add("sun");// 包含sunw
excludePackage.add("com/sun");
excludePackage.add("org");// 包含org/xml org/jboss org/apache/xerces org/objectweb/asm
excludePackage.add("java/");// 包含javax
excludePackage.add("sun/");// 包含sunw
excludePackage.add("com/sun/");
excludePackage.add("org/");// 包含org/xml org/jboss org/apache/xerces org/objectweb/asm
// 不注入profile本身
excludePackage.add("com/taobao/profile");
excludePackage.add("com/taobao/hsf");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ProfTransformer implements ClassFileTransformer {
*/
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
if (ProfFilter.isNotNeedInjectClassLoader(loader.getClass().getName())) {
if (loader != null && ProfFilter.isNotNeedInjectClassLoader(loader.getClass().getName())) {
return classfileBuffer;
}
if (!ProfFilter.isNeedInject(className)) {
Expand All @@ -43,7 +43,7 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
return classfileBuffer;
}
if (Manager.instance().isDebugMode()) {
System.out.println(" ---- TProfiler Debug: " + loader.getClass().getName() + " ---- " + className);
System.out.println(" ---- TProfiler Debug: ClassLoader:" + loader + " ---- class: " + className);
}

// 记录注入类数
Expand Down

0 comments on commit dc4badb

Please sign in to comment.