Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 329048

Summary: SDO: User-set ApplicationResolver is not being utilized if the WLS ExecuteThread is null
Product: z_Archived Reporter: David McCann <david.mccann>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed code changes for the 2.1.2 stream
none
Proposed code changes for the 2.2 stream none

Description David McCann CLA 2010-10-29 09:45:24 EDT
In the case where the current thread is non-wls managed the ExecuteThread is null.  Since our code only uses the ApplicationResolver when ExecuteThread doesn't return the app name, we never use the resolver if the ExecuteThread is null.  We need to use the ApplicationResolver if ExecuteThread is null, or the returned application name is null.
Comment 1 David McCann CLA 2010-10-29 09:47:23 EDT
The code that looks up the WLS application name should be changed as follows:

// Helper contexts in WebLogic server will be keyed on application 
// name if available
if (classLoaderName.contains(WLS_CLASSLOADER_NAME)) {
  Object appName = null;
  Object executeThread = getExecuteThread();
  if (executeThread != null) {
    try {
      Method getMethod = 
        PrivilegedAccessHelper.getPublicMethod(executeThread.getClass(), 
        WLS_APPLICATION_NAME_GET_METHOD_NAME, WLS_PARAMETER_TYPES, false);
      appName = PrivilegedAccessHelper.invokeMethod(getMethod, executeThread);
    } catch (Exception e) {
      throw SDOException.errorInvokingWLSMethodReflectively(
        WLS_APPLICATION_NAME_GET_METHOD_NAME, WLS_EXECUTE_THREAD, e);
    }
  }
  // if ExecuteThread is null or doesn't return the app name, attempt 
  // to use the user-set ApplicationResolver (if set)
  if (appName == null && appResolver != null) {
    appName = appResolver.getApplicationName();
  }
  // use the application name if set, otherwise key on the class loader
  if (appName != null) {
    return new MapKeyLookupResult(appName.toString(), classLoader);
  } 
  // couldn't get the application name, so default to the context loader
  return new MapKeyLookupResult(classLoader);
}
Comment 2 David McCann CLA 2010-10-29 10:52:00 EDT
Created attachment 182049 [details]
Proposed code changes for the 2.1.2 stream
Comment 3 David McCann CLA 2010-10-29 10:52:14 EDT
Created attachment 182050 [details]
Proposed code changes for the 2.2 stream
Comment 4 David McCann CLA 2010-11-01 10:34:55 EDT
Reviewed by:  blaise.doughan@oracle.com; matt.macivor@oracle.com
Tests:  all unit tests pass as expected

2.1.2 rev 8448
2.2 rev 8449
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:31:36 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink