Skip to content

Remove reflection call ScheduledThreadPoolExecutor#setRemoveOnCancelPolicy(boolean) #74

@apupier

Description

@apupier

/**
* {@link ScheduledThreadPoolExecutor#setRemoveOnCancelPolicy(boolean)} is not available in Java
* 6 so we invoke it with reflection to be able to compile against Java 6.
*
* @param executor
*/
private static void safeSetRemoveOnCancel(ScheduledThreadPoolExecutor executor) {
try {
executor.getClass().getMethod("setRemoveOnCancelPolicy", boolean.class).invoke(executor, Boolean.TRUE);
} catch (IllegalAccessException e) {
throwSetRemoveOnCancelException(e);
} catch (IllegalArgumentException e) {
throwSetRemoveOnCancelException(e);
} catch (InvocationTargetException e) {
throwSetRemoveOnCancelException(e.getCause());
} catch (NoSuchMethodException e) {
throw new SdkClientException("The request timeout feature is only available for Java 1.7 and above.");
} catch (SecurityException e) {
throw new SdkClientException("The request timeout feature needs additional permissions to function.", e);
}
}

it was called reflectively to be compilable with Java 6, but now the minimal version Java 1.8

<jre.version>1.8</jre.version>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions