Search in sources :

Example 21 with PinpointException

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;
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) PinpointException(com.navercorp.pinpoint.exception.PinpointException)

Example 22 with PinpointException

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);
    }
}
Also used : PinpointException(com.navercorp.pinpoint.exception.PinpointException) ByStaticFactoryMethod(com.navercorp.pinpoint.bootstrap.plugin.ObjectFactory.ByStaticFactoryMethod) Method(java.lang.reflect.Method) PinpointException(com.navercorp.pinpoint.exception.PinpointException)

Example 23 with PinpointException

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);
    }
}
Also used : PinpointException(com.navercorp.pinpoint.exception.PinpointException) PinpointException(com.navercorp.pinpoint.exception.PinpointException)

Example 24 with PinpointException

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();
    }
}
Also used : GuardInstrumentor(com.navercorp.pinpoint.profiler.instrument.GuardInstrumentor) InstrumentException(com.navercorp.pinpoint.bootstrap.instrument.InstrumentException) PinpointException(com.navercorp.pinpoint.exception.PinpointException) InstrumentContext(com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)

Example 25 with PinpointException

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");
}
Also used : URLClassLoader(java.net.URLClassLoader) PinpointException(com.navercorp.pinpoint.exception.PinpointException) PinpointException(com.navercorp.pinpoint.exception.PinpointException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

PinpointException (com.navercorp.pinpoint.exception.PinpointException)25 TargetConstructor (com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetConstructor)4 TargetConstructors (com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetConstructors)4 TargetFilter (com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetFilter)4 TargetMethod (com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethod)4 TargetMethods (com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethods)4 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 InstrumentContext (com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext)2 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)2 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)2 GuardInstrumentor (com.navercorp.pinpoint.profiler.instrument.GuardInstrumentor)2 FilteringMethodTransformer (com.navercorp.pinpoint.profiler.plugin.xml.transformer.FilteringMethodTransformer)2 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)1 MethodFilter (com.navercorp.pinpoint.bootstrap.instrument.MethodFilter)1 ByStaticFactoryMethod (com.navercorp.pinpoint.bootstrap.plugin.ObjectFactory.ByStaticFactoryMethod)1 SimpleClassMetadata (com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata)1 AutoBindingObjectFactory (com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory)1 InterceptorArgumentProvider (com.navercorp.pinpoint.profiler.objectfactory.InterceptorArgumentProvider)1 ClassCookBook (com.navercorp.pinpoint.profiler.plugin.xml.transformer.ClassCookBook)1 DedicatedMethodTransformer (com.navercorp.pinpoint.profiler.plugin.xml.transformer.DedicatedMethodTransformer)1