java.lang.reflect.UndeclaredThrowableException Java Examples

The following examples show how to use java.lang.reflect.UndeclaredThrowableException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserGroupInformation.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Run the given action as the user, potentially throwing an exception.
 * @param <T> the return type of the run method
 * @param action the method to execute
 * @return the value from the run method
 * @throws IOException if the action throws an IOException
 * @throws Error if the action throws an Error
 * @throws RuntimeException if the action throws a RuntimeException
 * @throws InterruptedException if the action throws an InterruptedException
 * @throws UndeclaredThrowableException if the action throws something else
 */
@InterfaceAudience.Public
@InterfaceStability.Evolving
public <T> T doAs(PrivilegedExceptionAction<T> action
                  ) throws IOException, InterruptedException {
  try {
    logPrivilegedAction(subject, action);
    return Subject.doAs(subject, action);
  } catch (PrivilegedActionException pae) {
    Throwable cause = pae.getCause();
    if (LOG.isDebugEnabled()) {
      LOG.debug("PrivilegedActionException as:" + this + " cause:" + cause);
    }
    if (cause instanceof IOException) {
      throw (IOException) cause;
    } else if (cause instanceof Error) {
      throw (Error) cause;
    } else if (cause instanceof RuntimeException) {
      throw (RuntimeException) cause;
    } else if (cause instanceof InterruptedException) {
      throw (InterruptedException) cause;
    } else {
      throw new UndeclaredThrowableException(cause);
    }
  }
}
 
Example #2
Source File: MAPTestBase.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testVersioning() throws Exception {
    try {
        // expect two MAPs instances versioned with 200408, i.e. for both
        // the partial and full responses
        mapVerifier.addToExpectedExposedAs(Names200408.WSA_NAMESPACE_NAME);
        mapVerifier.addToExpectedExposedAs(Names200408.WSA_NAMESPACE_NAME);
        String greeting = greeter.greetMe("versioning1");
        assertEquals("unexpected response received from service",
                     "Hello versioning1",
                     greeting);
        checkVerification();
        greeting = greeter.greetMe("versioning2");
        assertEquals("unexpected response received from service",
                     "Hello versioning2",
                     greeting);
        checkVerification();
    } catch (UndeclaredThrowableException ex) {
        throw (Exception)ex.getCause();
    }
}
 
Example #3
Source File: AbstractAspectJAdvisorFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testAspectMethodThrowsExceptionIllegalOnSignature() {
	TestBean target = new TestBean();
	RemoteException expectedException = new RemoteException();
	List<Advisor> advisors = getFixture().getAdvisors(
			new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException), "someBean"));
	assertEquals("One advice method was found", 1, advisors.size());
	ITestBean itb = (ITestBean) createProxy(target, advisors, ITestBean.class);

	try {
		itb.getAge();
		fail();
	}
	catch (UndeclaredThrowableException ex) {
		assertSame(expectedException, ex.getCause());
	}
}
 
Example #4
Source File: FlinkYarnSessionCli.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
	final String configurationDirectory = CliFrontend.getConfigurationDirectoryFromEnv();

	final Configuration flinkConfiguration = GlobalConfiguration.loadConfiguration();

	int retCode;

	try {
		final FlinkYarnSessionCli cli = new FlinkYarnSessionCli(
			flinkConfiguration,
			configurationDirectory,
			"",
			""); // no prefix for the YARN session

		SecurityUtils.install(new SecurityConfiguration(flinkConfiguration));

		retCode = SecurityUtils.getInstalledContext().runSecured(() -> cli.run(args));
	} catch (CliArgsException e) {
		retCode = handleCliArgsException(e);
	} catch (Throwable t) {
		final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
		retCode = handleError(strippedThrowable);
	}

	System.exit(retCode);
}
 
Example #5
Source File: ClientServerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testNillable() throws Exception {
    SOAPService service = new SOAPService();
    assertNotNull(service);

    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);

    try {
        String reply = greeter.testNillable("test", 100);
        assertEquals("test", reply);
        reply = greeter.testNillable(null, 100);
        assertNull(reply);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception)ex.getCause();
    }

}
 
Example #6
Source File: ConfigurationValueInjector.java    From webtester2-core with Apache License 2.0 6 votes vote down vote up
private void injectField(Configuration config, Field field, Object target) {

        ConfigurationValue configurationValue = field.getAnnotation(ConfigurationValue.class);
        if (configurationValue == null) {
            // field should not be injected
            return;
        }

        field.setAccessible(true);

        Injector injector = injectorMap.get(field.getType());
        if (injector == null) {
            throw new IllegalClassException(UNINJECTABLE_FIELD_TYPE + field.getType());
        }

        try {
            injector.injectInto(config, configurationValue.value(), field, target);
        } catch (IllegalAccessException e) {
            /* since fields are set accessible at the beginning of this method  IllegalAccessExceptions should not occur.
             * That makes it ok to throw an UndeclaredThrowableException */
            throw new UndeclaredThrowableException(e);
        }

    }
 
Example #7
Source File: VertexManager.java    From tez with Apache License 2.0 6 votes vote down vote up
@Override
public void onFailure(Throwable t) {
  try {
    Preconditions.checkState(eventInFlight.get());
    // stop further event processing
    pluginFailed.set(true);
    eventQueue.clear();
    // catch real root cause of failure, it would throw UndeclaredThrowableException
    // if using UGI.doAs
    if (t instanceof UndeclaredThrowableException) {
      t = t.getCause();
    }
    Preconditions.checkState(appContext != null);
    Preconditions.checkState(managedVertex != null);
    // state change must be triggered via an event transition
    appContext.getEventHandler().handle(
        new VertexEventManagerUserCodeError(managedVertex.getVertexId(),
            new AMUserCodeException(Source.VertexManager, t)));
    // enqueue no further events due to user code error
  } catch (Exception e) {
    sendInternalError(e);
  }
}
 
Example #8
Source File: Event.java    From bulbasaur with Apache License 2.0 6 votes vote down vote up
@Override
public StateLike parse(Element elem) {
    super.parse(elem);
    List<Element> pre_invokesPaths = elem.selectNodes(PRE_INVOKES_TAG);
    for (Element node : pre_invokesPaths) {// 拿 孩子节点
        for (Iterator i = node.elementIterator(); i.hasNext(); ) {
            Element child = (Element)i.next();
            try {
                preInvokes.add(InvokableFactory.newInstance(child.getName(), child));
            } catch (RuntimeException re) {
                logger.error(String.format("实例Invokable类型时候出错,类型为:%s , 异常为: %s", child.getName(), re.toString()));
                throw re;
            } catch (Throwable e) {
                logger.error(String.format("实例Invokable类型时候出错,类型为: %s , 异常为:", child.getName(), e.toString()));
                throw new UndeclaredThrowableException(e,
                    "error happened when newInstance Invokable class:" + child.getName());
            }
        }
    }
    return this;
}
 
Example #9
Source File: SpliceFailFastInterceptor.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void handleFailure(RetryingCallerInterceptorContext context, Throwable t) throws IOException {

    if (t instanceof UndeclaredThrowableException) {
        t = t.getCause();
    }
    if (t instanceof RemoteException) {
        RemoteException re = (RemoteException)t;
        t = re.unwrapRemoteException();
    }
    if (t instanceof DoNotRetryIOException) {
        throw (DoNotRetryIOException)t;
    }
    if (t instanceof IOException) {
        throw (IOException) t;
    }
    throw new IOException(t);
}
 
Example #10
Source File: DistributedVI.java    From toolbox with Apache License 2.0 6 votes vote down vote up
public DataSet<DataPosterior> computePosterior(){

        Attribute seq_id = this.dataFlink.getAttributes().getSeq_id();
        if (seq_id==null)
            throw new IllegalArgumentException("Functionality only available for data sets with a seq_id attribute");

        try{
            Configuration config = new Configuration();
            config.setString(ParameterLearningAlgorithm.BN_NAME, this.dag.getName());
            config.setBytes(SVB, Serialization.serializeObject(svb));

            return this.dataFlink
                    .getBatchedDataSet(this.batchSize)
                    .flatMap(new ParallelVBMapInference())
                    .withParameters(config);

        }catch(Exception ex){
            throw new UndeclaredThrowableException(ex);
        }

    }
 
Example #11
Source File: ReflectionUtils.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Handle the given reflection exception. Should only be called if no
 * checked exception is expected to be thrown by the target method.
 * <p>Throws the underlying RuntimeException or Error in case of an
 * InvocationTargetException with such a root cause. Throws an
 * IllegalStateException with an appropriate message or
 * UndeclaredThrowableException otherwise.
 * @param ex the reflection exception to handle
 */
public static void handleReflectionException(Exception ex) {
	if (ex instanceof NoSuchMethodException) {
		throw new IllegalStateException("Method not found: " + ex.getMessage());
	}
	if (ex instanceof IllegalAccessException) {
		throw new IllegalStateException("Could not access method: " + ex.getMessage());
	}
	if (ex instanceof InvocationTargetException) {
		handleInvocationTargetException((InvocationTargetException) ex);
	}
	if (ex instanceof RuntimeException) {
		throw (RuntimeException) ex;
	}
	throw new UndeclaredThrowableException(ex);
}
 
Example #12
Source File: CollectorFormatter.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets and creates the formatter from the LogManager or creates the default
 * formatter.
 *
 * @param p the class name prefix.
 * @return the formatter.
 * @throws NullPointerException if the given argument is null.
 * @throws UndeclaredThrowableException if the formatter can not be created.
 */
private Formatter initFormatter(final String p) {
    Formatter f;
    String v = fromLogManager(p.concat(".formatter"));
    if (v != null && v.length() != 0) {
        if (!"null".equalsIgnoreCase(v)) {
            try {
                f = LogManagerProperties.newFormatter(v);
            } catch (final RuntimeException re) {
                throw re;
            } catch (final Exception e) {
                throw new UndeclaredThrowableException(e);
            }
        } else {
            f = null;
        }
    } else {
        //Don't force the byte code verifier to load the formatter.
        f = Formatter.class.cast(new CompactFormatter());
    }
    return f;
}
 
Example #13
Source File: AbstractHBaseConnectionHelper.java    From datacollector with Apache License 2.0 6 votes vote down vote up
public static void handleHBaseException(
    Throwable t, Iterator<Record> records, ErrorRecordHandler errorRecordHandler
) throws StageException {
  Throwable cause = t;

  // Drill down to root cause
  while ((
      cause instanceof UncheckedExecutionException ||
          cause instanceof UndeclaredThrowableException ||
          cause instanceof ExecutionException
  ) && cause.getCause() != null) {
    cause = cause.getCause();
  }

  // Column is null or No such Column Family exception
  if (cause instanceof NullPointerException || cause instanceof NoSuchColumnFamilyException) {
    while (records.hasNext()) {
      Record record = records.next();
      errorRecordHandler.onError(new OnRecordErrorException(record, Errors.HBASE_37, cause));
    }
  } else {
    LOG.error(Errors.HBASE_36.getMessage(), cause.toString(), cause);
    throw new StageException(Errors.HBASE_36, cause.toString(), cause);
  }
}
 
Example #14
Source File: RESTExceptionMapperTest.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Test
public void testToResponse_GetClassAndCause2() {
    Exception e = new UndeclaredThrowableException(null, "java.lang.IllegalArgumentException: ");
    StackTraceElement[] traceArr = new StackTraceElement[1];
    traceArr[0] = new StackTraceElement("dummyClass", "dummyMethod", null, 0);
    
    e.setStackTrace(traceArr);
    
    Response response = rem.toResponse(e);
    MultivaluedMap<String,Object> responseMap = response.getHeaders();
    
    Assert.assertEquals(400, response.getStatus());
    Assert.assertEquals(6, responseMap.size());
    Assert.assertEquals(Lists.newArrayList(true), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS));
    Assert.assertEquals(Lists.newArrayList("*"), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
    Assert.assertEquals(Lists.newArrayList(864000), responseMap.get(HttpHeaders.ACCESS_CONTROL_MAX_AGE));
    Assert.assertEquals(Lists.newArrayList("400-1"), responseMap.get(Constants.ERROR_CODE));
    Assert.assertEquals(Lists.newArrayList("null/null"), responseMap.get(Constants.RESPONSE_ORIGIN));
    Assert.assertEquals(Lists.newArrayList("X-SSL-ClientCert-Subject, X-ProxiedEntitiesChain, X-ProxiedIssuersChain, Accept, Accept-Encoding"),
                    responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS));
}
 
Example #15
Source File: dVMPv1.java    From toolbox with Apache License 2.0 6 votes vote down vote up
public DataSet<DataPosterior> computePosterior(DataFlink<DataInstance> dataFlink, List<Variable> latentVariables){

        Attribute seq_id = dataFlink.getAttributes().getSeq_id();
        if (seq_id==null)
            throw new IllegalArgumentException("Functionality only available for data sets with a seq_id attribute");

        try{
            Configuration config = new Configuration();
            config.setString(ParameterLearningAlgorithm.BN_NAME, this.dag.getName());
            config.setBytes(SVB, Serialization.serializeObject(svb));
            config.setBytes(LATENT_VARS, Serialization.serializeObject(latentVariables));

            return dataFlink
                    .getBatchedDataSet(this.batchSize)
                    .flatMap(new ParallelVBMapInference())
                    .withParameters(config);

        }catch(Exception ex){
            throw new UndeclaredThrowableException(ex);
        }

    }
 
Example #16
Source File: ReflectionUtils.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handle the given reflection exception. Should only be called if no
 * checked exception is expected to be thrown by the target method.
 * <p>Throws the underlying RuntimeException or Error in case of an
 * InvocationTargetException with such a root cause. Throws an
 * IllegalStateException with an appropriate message or
 * UndeclaredThrowableException otherwise.
 * @param ex the reflection exception to handle
 */
public static void handleReflectionException(Exception ex) {
	if (ex instanceof NoSuchMethodException) {
		throw new IllegalStateException("Method not found: " + ex.getMessage());
	}
	if (ex instanceof IllegalAccessException) {
		throw new IllegalStateException("Could not access method: " + ex.getMessage());
	}
	if (ex instanceof InvocationTargetException) {
		handleInvocationTargetException((InvocationTargetException) ex);
	}
	if (ex instanceof RuntimeException) {
		throw (RuntimeException) ex;
	}
	throw new UndeclaredThrowableException(ex);
}
 
Example #17
Source File: dVMP.java    From toolbox with Apache License 2.0 6 votes vote down vote up
public DataSet<DataPosterior> computePosterior(DataFlink<DataInstance> dataFlink){

        Attribute seq_id = dataFlink.getAttributes().getSeq_id();
        if (seq_id==null)
            throw new IllegalArgumentException("Functionality only available for data sets with a seq_id attribute");

        try{
            Configuration config = new Configuration();
            config.setString(ParameterLearningAlgorithm.BN_NAME, this.getName());
            config.setBytes(SVB, Serialization.serializeObject(svb));

            return dataFlink
                    .getBatchedDataSet(this.batchSize,batchConverter)
                    .flatMap(new ParallelVBMapInference())
                    .withParameters(config);

        }catch(Exception ex){
            throw new UndeclaredThrowableException(ex);
        }

    }
 
Example #18
Source File: ReflectionUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Handle the given reflection exception. Should only be called if no
 * checked exception is expected to be thrown by the target method.
 * <p>Throws the underlying RuntimeException or Error in case of an
 * InvocationTargetException with such a root cause. Throws an
 * IllegalStateException with an appropriate message else.
 * @param ex the reflection exception to handle
 */
public static void handleReflectionException(Exception ex) {
	if (ex instanceof NoSuchMethodException) {
		throw new IllegalStateException("Method not found: " + ex.getMessage());
	}
	if (ex instanceof IllegalAccessException) {
		throw new IllegalStateException("Could not access method: " + ex.getMessage());
	}
	if (ex instanceof InvocationTargetException) {
		handleInvocationTargetException((InvocationTargetException) ex);
	}
	if (ex instanceof RuntimeException) {
		throw (RuntimeException) ex;
	}
	throw new UndeclaredThrowableException(ex);
}
 
Example #19
Source File: ReflectionUtils.java    From dolphin with Apache License 2.0 6 votes vote down vote up
/**
 * Handle the given reflection exception. Should only be called if no
 * checked exception is expected to be thrown by the target method.
 * <p>Throws the underlying RuntimeException or Error in case of an
 * InvocationTargetException with such a root cause. Throws an
 * IllegalStateException with an appropriate message else.
 * @param ex the reflection exception to handle
 */
public static void handleReflectionException(Exception ex) {
	if (ex instanceof NoSuchMethodException) {
		throw new IllegalStateException("Method not found: " + ex.getMessage());
	}
	if (ex instanceof IllegalAccessException) {
		throw new IllegalStateException("Could not access method: " + ex.getMessage());
	}
	if (ex instanceof InvocationTargetException) {
		handleInvocationTargetException((InvocationTargetException) ex);
	}
	if (ex instanceof RuntimeException) {
		throw (RuntimeException) ex;
	}
	throw new UndeclaredThrowableException(ex);
}
 
Example #20
Source File: ClientServerVersioningTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testVersionBasedRouting() throws Exception {

    SOAPService service = new SOAPService();
    assertNotNull(service);

    try {
        Greeter greeter = service.getPort(portName, Greeter.class);
        updateAddressPort(greeter, PORT);

        GreetMe1 request = new GreetMe1();
        request.setRequestType("Bonjour");
        GreetMeResponse greeting = greeter.greetMe(request);
        assertNotNull("no response received from service", greeting);
        assertEquals("Hello Bonjour version1", greeting.getResponseType());

        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals("Bonjour version2", reply);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception)ex.getCause();
    }
}
 
Example #21
Source File: dVMPv1.java    From toolbox with Apache License 2.0 6 votes vote down vote up
public DataSet<DataPosteriorAssignment> computePosteriorAssignment(DataFlink<DataInstance> dataFlink, List<Variable> latentVariables){

        Attribute seq_id = dataFlink.getAttributes().getSeq_id();
        if (seq_id==null)
            throw new IllegalArgumentException("Functionality only available for data sets with a seq_id attribute");

        try{
            Configuration config = new Configuration();
            config.setString(ParameterLearningAlgorithm.BN_NAME, this.dag.getName());
            config.setBytes(SVB, Serialization.serializeObject(svb));
            config.setBytes(LATENT_VARS, Serialization.serializeObject(latentVariables));

            return dataFlink
                    .getBatchedDataSet(this.batchSize)
                    .flatMap(new ParallelVBMapInferenceAssignment())
                    .withParameters(config);

        }catch(Exception ex){
            throw new UndeclaredThrowableException(ex);
        }

    }
 
Example #22
Source File: ExceptionUtil.java    From vjtools with Apache License 2.0 5 votes vote down vote up
/**
 * 如果是著名的包裹类,从cause中获得真正异常. 其他异常则不变.
 * 
 * Future中使用的ExecutionException 与 反射时定义的InvocationTargetException, 真正的异常都封装在Cause中
 * 
 * 前面 unchecked() 使用的UncheckedException同理.
 */
public static Throwable unwrap(@Nullable Throwable t) {
	if (t instanceof UncheckedException || t instanceof java.util.concurrent.ExecutionException
			|| t instanceof java.lang.reflect.InvocationTargetException
			|| t instanceof UndeclaredThrowableException) {
		return t.getCause();
	}

	return t;
}
 
Example #23
Source File: ClientServerWebSocketTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBasicConnectionAndOneway() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);

    SOAPService service = new SOAPService(wsdl, serviceName);

    Greeter greeter = service.getPort(portName, Greeter.class);
    updateGreeterAddress(greeter, PORT);

    String response1 = new String("Hello Milestone-");
    String response2 = new String("Bonjour");
    try {
        for (int idx = 0; idx < 1; idx++) {
            String greeting = greeter.greetMe("Milestone-" + idx);
            assertNotNull("no response received from service", greeting);
            String exResponse = response1 + idx;
            assertEquals(exResponse, greeting);

            String reply = greeter.sayHi();
            assertNotNull("no response received from service", reply);
            assertEquals(response2, reply);

            greeter.greetMeOneWay("Milestone-" + idx);



        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception)ex.getCause();
    }
}
 
Example #24
Source File: RemoteOfflineApplicationImpl.java    From ipst with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void refreshAll() {
    try {
        getJmxContext().getApplication().refreshAll();
    } catch (IOException | JMException | UndeclaredThrowableException e) {
        discardJmxContext();
    }
}
 
Example #25
Source File: Methods.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static <T> Object call(Class<T> clazz, T instance, String methodName,
    Class[] types, Object[] args) throws Exception {
  try {
    Method m = clazz.getMethod(methodName, types);
    return m.invoke(instance, args);
  } catch (IllegalArgumentException arge) {
    LOG.error(HBaseMarkers.FATAL, "Constructed invalid call. class="+clazz.getName()+
        " method=" + methodName + " types=" + Classes.stringify(types), arge);
    throw arge;
  } catch (NoSuchMethodException nsme) {
    throw new IllegalArgumentException(
        "Can't find method "+methodName+" in "+clazz.getName()+"!", nsme);
  } catch (InvocationTargetException ite) {
    // unwrap the underlying exception and rethrow
    if (ite.getTargetException() != null) {
      if (ite.getTargetException() instanceof Exception) {
        throw (Exception)ite.getTargetException();
      } else if (ite.getTargetException() instanceof Error) {
        throw (Error)ite.getTargetException();
      }
    }
    throw new UndeclaredThrowableException(ite,
        "Unknown exception invoking "+clazz.getName()+"."+methodName+"()");
  } catch (IllegalAccessException iae) {
    throw new IllegalArgumentException(
        "Denied access calling "+clazz.getName()+"."+methodName+"()", iae);
  } catch (SecurityException se) {
    LOG.error(HBaseMarkers.FATAL, "SecurityException calling method. class="+
        clazz.getName()+" method=" + methodName + " types=" +
        Classes.stringify(types), se);
    throw se;
  }
}
 
Example #26
Source File: DocWriter.java    From vertx-docgen with Apache License 2.0 5 votes vote down vote up
@Override
public void write(char[] cbuf) {
  try {
    super.write(cbuf);
  } catch (IOException e) {
    throw new UndeclaredThrowableException(e);
  }
}
 
Example #27
Source File: ThrowExceptionMatcher.java    From webtau with Apache License 2.0 5 votes vote down vote up
private void extractExceptionDetails(Throwable t) {
    if (t instanceof UndeclaredThrowableException) {
        Throwable undeclaredCheckedException = t.getCause();
        thrownMessage = undeclaredCheckedException.getMessage();
        thrownClass = undeclaredCheckedException.getClass();
    } else {
        thrownMessage = t.getMessage();
        thrownClass = t.getClass();
    }
}
 
Example #28
Source File: ReflectionUtils.java    From webtester2-core with Apache License 2.0 5 votes vote down vote up
public void setValue(Field field, Object instance, Object value) {
    try {
        field.setAccessible(true);
        field.set(instance, value);
    } catch (IllegalAccessException e) {
        // should not happen because field is made accessible
        throw new UndeclaredThrowableException(e);
    }
}
 
Example #29
Source File: AwsSigner4Request.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
byte[] getBytes() {
    if (request instanceof HttpEntityEnclosingRequestBase) {
        try {
            HttpEntity entity = ((HttpEntityEnclosingRequestBase) request).getEntity();
            return EntityUtils.toByteArray(entity);
        } catch (IOException e) {
            throw new UndeclaredThrowableException(e);
        }
    }
    return EMPTY_BYTES;
}
 
Example #30
Source File: YarnTaskExecutorRunner.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * The instance entry point for the YARN task executor. Obtains user group information and calls
 * the main work method {@link TaskManagerRunner#runTaskManager(Configuration, PluginManager)} as a
 * privileged action.
 *
 * @param args The command line arguments.
 */
private static void runTaskManagerSecurely(String[] args) {
	try {
		LOG.debug("All environment variables: {}", ENV);

		final String currDir = ENV.get(Environment.PWD.key());
		LOG.info("Current working Directory: {}", currDir);

		final Configuration configuration = TaskManagerRunner.loadConfiguration(args);

		final PluginManager pluginManager = PluginUtils.createPluginManagerFromRootFolder(configuration);

		FileSystem.initialize(configuration, pluginManager);

		setupConfigurationAndInstallSecurityContext(configuration, currDir, ENV);

		SecurityUtils.getInstalledContext().runSecured((Callable<Void>) () -> {
			TaskManagerRunner.runTaskManager(configuration, pluginManager);
			return null;
		});
	}
	catch (Throwable t) {
		final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
		// make sure that everything whatever ends up in the log
		LOG.error("YARN TaskManager initialization failed.", strippedThrowable);
		System.exit(INIT_ERROR_EXIT_CODE);
	}
}