[
https://issues.apache.org/jira/browse/DERBY-6107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944923#comment-13944923
]
Knut Anders Hatlen commented on DERBY-6107:
-------------------------------------------
I tried wrapping the callable in InternalDriver.timeLogin() using said helper
method in Executors, like this:
{code}
final LoginCallable callable = new LoginCallable(this, url, info);
Future<EmbedConnection> task = _executorPool.submit(
AccessController.doPrivileged(new
PrivilegedAction<Callable<EmbedConnection>>() {
public Callable<EmbedConnection> run() {
return
Executors.privilegedCallableUsingCurrentClassLoader(callable);
}
}));
{code}
That made the test pass in my environment.
This only works if derby.jar has been granted the runtime permissions
getClassLoader and setContextClassLoader. Those permissions are currently
listed as optional permissions. If we go for this approach, we'd either need to
make them required permissions (at least required when using login timeout), or
have a reasonable fallback strategy if the permissions have not been granted.
One possible fallback strategy might be to set the keep alive time for
InternalDriver's thread pool to 0. That would cause every submitted task to
spawn a new thread, so they would never end up executing in a thread whose
context class loader was inherited from a thread that submitted an earlier
task. That means you won't get the benefit of reusing threads from the thread
pool if you don't have those permissions, but at least it will behave correctly.
Or maybe, for simplicity, we should just set the keep alive time to 0
unconditionally, and skip the use of
Executors.privilegedCallableUsingCurrentClassLoader(), so that we wouldn't have
two different code paths depending on whether or not the permissions have been
granted. In most cases I would suppose the getConnection() call isn't very
performance critical, so it might not be worth the extra complexity to optimize
it.
> Investigate why setting a login timeout causes
> NativeAuthenticationServiceTest to fail when run in a suite
> ----------------------------------------------------------------------------------------------------------
>
> Key: DERBY-6107
> URL: https://issues.apache.org/jira/browse/DERBY-6107
> Project: Derby
> Issue Type: Bug
> Components: Test
> Affects Versions: 10.10.1.1
> Reporter: Rick Hillegas
> Assignee: Knut Anders Hatlen
>
> See DERBY-6094 for the details of this problem.
--
This message was sent by Atlassian JIRA
(v6.2#6252)