use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class DefaultAsyncTraceContext method checkAndGet.
private Reference<Trace> checkAndGet() {
final Reference<Trace> reference = this.binder.get();
final Trace old = reference.get();
if (old != null) {
final PinpointException exception = new PinpointException("already Trace Object exist.");
if (logger.isWarnEnabled()) {
logger.warn("beforeTrace:{}", old, exception);
}
throw exception;
}
return reference;
}
use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class AutoBindingObjectFactory method byStaticFactoryMethod.
private Object byStaticFactoryMethod(Class<?> type, ByStaticFactoryMethod staticFactoryMethod, ArgumentsResolver argumentsResolver) {
StaticMethodResolver resolver = new StaticMethodResolver(type, staticFactoryMethod.getFactoryMethodName(), argumentsResolver);
if (!resolver.resolve()) {
throw new PinpointException("Cannot find suitable factory method " + type.getName() + "." + staticFactoryMethod.getFactoryMethodName());
}
final Method method = resolver.getResolvedMethod();
final Object[] resolvedArguments = resolver.getResolvedArguments();
if (isDebug) {
logger.debug("Create instance by static factory method {}, with arguments {}", method, Arrays.toString(resolvedArguments));
}
try {
return method.invoke(null, resolvedArguments);
} catch (Exception e) {
throw new PinpointException("Fail to invoke factory method: " + type.getName() + "." + staticFactoryMethod.getFactoryMethodName() + ", arguments: " + Arrays.toString(resolvedArguments), e);
}
}
use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class AutoBindingObjectFactory method byConstructor.
private Object byConstructor(Class<?> type, ArgumentsResolver argumentsResolver) {
final ConstructorResolver resolver = new ConstructorResolver(type, argumentsResolver);
if (!resolver.resolve()) {
throw new PinpointException("Cannot find suitable constructor for " + type.getName());
}
final Constructor<?> constructor = resolver.getResolvedConstructor();
final Object[] resolvedArguments = resolver.getResolvedArguments();
if (isDebug) {
logger.debug("Create instance by constructor {}, with arguments {}", constructor, Arrays.toString(resolvedArguments));
}
try {
return constructor.newInstance(resolvedArguments);
} catch (Exception e) {
throw new PinpointException("Fail to invoke constructor: " + constructor + ", arguments: " + Arrays.toString(resolvedArguments), e);
}
}
use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class ClassFileTransformerDelegate method transform.
@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
Objects.requireNonNull(className, "className");
final InstrumentContext instrumentContext = this.instrumentContext;
final GuardInstrumentor guard = new GuardInstrumentor(this.profilerConfig, instrumentContext);
try {
// WARN external plugin api
final TransformCallback transformCallback = this.transformCallbackProvider.getTransformCallback(instrumentContext, loader);
return transformCallback.doInTransform(guard, loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
} catch (InstrumentException e) {
throw new PinpointException(e);
} finally {
guard.close();
}
}
use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class URLClassLoaderHandler method injectClass.
@Override
@SuppressWarnings("unchecked")
public <T> Class<? extends T> injectClass(ClassLoader classLoader, String className) {
try {
if (classLoader instanceof URLClassLoader) {
final URLClassLoader urlClassLoader = (URLClassLoader) classLoader;
addPluginURLIfAbsent(urlClassLoader);
return (Class<T>) urlClassLoader.loadClass(className);
}
} catch (Exception e) {
logger.warn("Failed to load plugin class {} with classLoader {}", className, classLoader, e);
throw new PinpointException("Failed to load plugin class " + className + " with classLoader " + classLoader, e);
}
throw new PinpointException("invalid ClassLoader");
}
Aggregations