idx
int64 0
165k
| question
stringlengths 73
4.15k
| target
stringlengths 5
918
| len_question
int64 21
890
| len_target
int64 3
255
|
---|---|---|---|---|
164,500 | public < T > Object getBeanKey ( Contextual < T > bean ) { if ( passivationCapable ) { // if the return ( ( PassivationCapable ) bean ) . getId ( ) ; } return bean ; } | If the context is a passivating scope then we return the passivationId of the Bean . Otherwise we use the Bean directly . | 50 | 26 |
164,501 | public Contextual < ? > getBean ( Object beanKey ) { if ( passivationCapable ) { return beanManager . getPassivationCapableBean ( ( String ) beanKey ) ; } else { return ( Contextual < ? > ) beanKey ; } } | Restores the Bean from its beanKey . | 58 | 9 |
164,502 | @ Override public ManagedService addingService ( ServiceReference < ManagedService > reference ) { String [ ] pids = getServicePid ( reference ) ; if ( pids == null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "handleRegistration(): Invalid service.pid type: " + reference ) ; } return null ; } ManagedService ms = context . getService ( reference ) ; if ( ms == null ) return null ; synchronized ( caFactory . getConfigurationStore ( ) ) { for ( String pid : pids ) { add ( reference , pid , ms ) ; } } return ms ; } | Processes registered ManagedService and updates each with their own configuration properties . | 148 | 15 |
164,503 | private LogRecord createLogRecord ( Level level , String msg , Object [ ] params , String sourceClassName , String sourceMethodName , String resourceBundleName , Throwable thrown ) { ResourceBundle resourceBundle = null ; if ( level . intValue ( ) >= this . ivMinimumLocalizationLevelIntValue ) { if ( null == this . ivCachedResourceBundle ) { this . ivCachedResourceBundle = super . getResourceBundle ( ) ; this . ivCachedResourceBundleName = super . getResourceBundleName ( ) ; } // if resourceBundleName not set by caller, look it up from logger // (and logger's parents if needed). if ( resourceBundleName == null ) { resourceBundleName = computeResourceBundleName ( ) ; } // get the resourceBundle if ( resourceBundleName != null ) { if ( resourceBundleName . equals ( this . ivCachedResourceBundleName ) ) { resourceBundle = this . ivCachedResourceBundle ; } else { resourceBundle = getResourceBundle ( resourceBundleName ) ; } } if ( null == resourceBundle && null != sourceClassName ) { try { Class < ? > source = Class . forName ( sourceClassName ) ; resourceBundle = ResourceBundle . getBundle ( resourceBundleName , Locale . getDefault ( ) , source . getClassLoader ( ) ) ; } catch ( Throwable t ) { // unable to find the resource bundle } } } return createWsLogRecord ( level , msg , params , sourceClassName , sourceMethodName , resourceBundleName , resourceBundle , thrown ) ; } | Creates a LogRecord using any available input parameters from the various Logger methods . | 358 | 17 |
164,504 | private WsLogRecord createWsLogRecord ( Level level , String msg , Object [ ] params , String sourceClassName , String sourceMethodName , String resourceBundleName , ResourceBundle resourceBundle , Throwable thrown ) { WsLogRecord logRecord = new WsLogRecord ( level , msg ) ; if ( params != null ) { logRecord . setParameters ( params ) ; // special handling for byte arrays in the first param position if ( ( params . length > 0 && params [ 0 ] != null ) && byte . class . equals ( params [ 0 ] . getClass ( ) . getComponentType ( ) ) ) logRecord . setRawData ( ( byte [ ] ) params [ 0 ] ) ; } if ( sourceClassName != null ) { logRecord . setSourceClassName ( sourceClassName ) ; } if ( sourceMethodName != null ) { logRecord . setSourceMethodName ( sourceMethodName ) ; } if ( resourceBundleName != null ) { logRecord . setResourceBundleName ( resourceBundleName ) ; } if ( resourceBundle != null ) { logRecord . setResourceBundle ( resourceBundle ) ; } if ( thrown != null ) { logRecord . setThrown ( thrown ) ; } if ( getName ( ) != null ) { logRecord . setLoggerName ( getName ( ) ) ; } if ( getOrganization ( ) != null ) { logRecord . setOrganization ( getOrganization ( ) ) ; } if ( getProduct ( ) != null ) { logRecord . setProduct ( getProduct ( ) ) ; } if ( getComponent ( ) != null ) { logRecord . setComponent ( getComponent ( ) ) ; } LogRecordContext . getExtensions ( logRecord . getExtensions ( ) ) ; logRecord . setTraceClass ( ivTC . getTraceClass ( ) ) ; // populate runtime data // Note: this is WAS version, UOW, process ID, etc // WsLoggerRuntimeData.getInstance().populate(logRecord); return logRecord ; } | Construct a WsLogRecord with the given level and message values . | 441 | 14 |
164,505 | private String computeResourceBundleName ( ) { Logger logger = this ; while ( logger != null ) { String name = logger . getResourceBundleName ( ) ; if ( name != null ) { return name ; } logger = logger . getParent ( ) ; } return null ; } | Worker method to determine the resource bundle name to use for logger . If set this is just the resource bundle name of this logger . If not set move up through the list of parents and find the first non - null resource bundle name . | 61 | 48 |
164,506 | private void introspectViaReflection ( ) { { Class < ? > memberClass = _member . getClass ( ) ; if ( memberClass . isArray ( ) ) { int length = Array . getLength ( _member ) ; Class < ? > componentType = memberClass . getComponentType ( ) ; if ( componentType . isPrimitive ( ) ) { addNewChild ( componentType + "[0.." + ( length - 1 ) + "]" , _member ) ; } else { String simpleName = componentType . getSimpleName ( ) ; for ( int i = 0 ; i < length && i < MAX_ARRAY_LENGTH ; i ++ ) { Object value = Array . get ( _member , i ) ; addNewChild ( simpleName + "[" + i + "]" , value ) ; } if ( length > MAX_ARRAY_LENGTH ) { addNewChild ( simpleName + "[...]" , "/* array length = " + length + " */" ) ; } } } else { /* * Loop around the fields of the object (including fields of its * superclass) adding them as children (and, it we haven't seen * the child before, getting introspected at the next level if * its worth doing so) */ Class < ? > currentClass = _member . getClass ( ) ; while ( currentClass != Object . class ) { Field [ ] fields = getFields ( currentClass ) ; for ( int i = 0 ; i < fields . length && i < MAX_ARRAY_LENGTH ; i ++ ) { final Field field = fields [ i ] ; Object value = getFieldValue ( field ) ; addNewChild ( field . getName ( ) , value ) ; } if ( fields . length > MAX_ARRAY_LENGTH ) { addNewChild ( "field..." , "/* total # of fields = " + fields . length + " */" ) ; } currentClass = currentClass . getSuperclass ( ) ; } } } } | Introspect the object via reflection | 426 | 7 |
164,507 | private void addNewChild ( String name , Object value ) { IntrospectionLevelMember prospectiveMember = new IntrospectionLevelMember ( _level + 1 , name , makeDescription ( value ) , makeMember ( value ) , _allKnownMembersInThisTree ) ; if ( makeMember ( value ) != null ) { // OK, we'd like to introspect the object further - have we seen it? if ( _allKnownMembersInThisTree . contains ( prospectiveMember ) ) { // Already seen it, so ensure we don't reexamine it prospectiveMember = new IntrospectionLevelMember ( _level + 1 , name , makeDescription ( value ) , null , _allKnownMembersInThisTree ) ; } else { // Ensure we don't reexamine it if we see it again! _allKnownMembersInThisTree . add ( prospectiveMember ) ; } } _children . add ( prospectiveMember ) ; } | Add a new IntrospectionLevelMember to _children List ( Checking to see if the new child should be introspected further | 191 | 25 |
164,508 | private Object getFieldValue ( final Field field ) { Object field_value = AccessController . doPrivileged ( new PrivilegedAction < Object > ( ) { @ Override public Object run ( ) { try { Object value = field . get ( _member ) ; // Don't dump sensitive data boolean sensitive = _member . getClass ( ) . isAnnotationPresent ( Sensitive . class ) || field . isAnnotationPresent ( Sensitive . class ) ; if ( value != null && sensitive ) { value = DataFormatHelper . sensitiveToString ( value ) ; } return value ; } catch ( IllegalAccessException e ) { // No FFDC code needed - we're in the middle of FFDC'ing! // Should not happen - if it does return a string :-) return "/* Could not access " + field . getName ( ) + " */" ; } } } ) ; return field_value ; } | Return the value of the member s field | 191 | 8 |
164,509 | private Field [ ] getFields ( final Class < ? > currentClass ) { final Field [ ] objectFields = AccessController . doPrivileged ( new PrivilegedAction < Field [ ] > ( ) { @ Override public Field [ ] run ( ) { try { Field [ ] tempObjectFields = currentClass . getDeclaredFields ( ) ; if ( tempObjectFields . length != 0 ) { AccessibleObject . setAccessible ( tempObjectFields , true ) ; } return tempObjectFields ; } catch ( Throwable t ) { // Introspection of field failed StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; t . printStackTrace ( pw ) ; addNewChild ( "Failed to resolve fields for " + currentClass . getName ( ) , sw . toString ( ) ) ; } return new Field [ 0 ] ; } } ) ; return objectFields ; } | Return the fields in a particular class | 205 | 7 |
164,510 | private String makeDescription ( Object value ) { String answer ; // Not initialized, so the compiler tells if we miss a // case if ( value == null ) { answer = "null" ; } else if ( value instanceof String ) { answer = "\"" + value + "\"" ; } else { Class < ? > objClass = value . getClass ( ) ; if ( ( objClass == Boolean . class ) || ( objClass == Character . class ) || ( objClass == Byte . class ) || ( objClass == Short . class ) || ( objClass == Integer . class ) || ( objClass == Long . class ) || ( objClass == Float . class ) || ( objClass == Double . class ) ) { answer = value . toString ( ) ; } else if ( objClass . isArray ( ) ) { if ( objClass . getComponentType ( ) . isPrimitive ( ) ) { answer = convertSimpleArrayToString ( value ) ; } else { answer = objClass . getComponentType ( ) + "[" + Array . getLength ( value ) + "]" ; } } else { answer = value . getClass ( ) . toString ( ) + "@" + Integer . toHexString ( System . identityHashCode ( value ) ) ; } } return answer ; } | Make a string that describes this object | 276 | 7 |
164,511 | public void print ( IncidentStream is , int maxDepth ) { StringBuffer fullName = new StringBuffer ( ) ; for ( int i = 0 ; i < _level ; i ++ ) fullName . append ( " " ) ; fullName . append ( _name ) ; is . writeLine ( fullName . toString ( ) , _description ) ; if ( _level < maxDepth ) { List < IntrospectionLevelMember > children = getChildren ( ) ; for ( IntrospectionLevelMember ilm : children ) { ilm . print ( is , maxDepth ) ; } } } | Print this IntrospectionLevelMember to an incident stream | 123 | 10 |
164,512 | public static RecoveryDirector recoveryDirector ( ) throws InternalLogException { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "recoveryDirector" ) ; // If the recovery director is null its an error in JET if ( _recoveryDirector == null ) { final InternalLogException ile = new InternalLogException ( ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "recoveryDirector" , ile ) ; throw ile ; } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "recoveryDirector" , _recoveryDirector ) ; return _recoveryDirector ; } | Returns the singleton instance of the RecoveryDirector class . This method uses reflection rather then a direct reference to the underlying class to avoid a cyclic build dependency . | 145 | 32 |
164,513 | public static RecoveryDirector createRecoveryDirector ( ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "createRecoveryDirector" ) ; _recoveryDirector = LibertyRecoveryDirectorImpl . instance ( ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "createRecoveryDirector" , _recoveryDirector ) ; return _recoveryDirector ; } | Create a RecoveryDirector singleton | 89 | 6 |