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

Bug 213930

Summary: Undesirable messages appear on console due to listener registered twice
Product: z_Archived Reporter: Kevin Mooney <kmooney>
Component: TPTPAssignee: Alex Nan <apnan>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: jkubasta, jptoomey, paulslau, slavescu
Version: unspecifiedKeywords: plan
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: closed460

Description Kevin Mooney CLA 2007-12-27 10:27:02 EST
Build ID: 200702051728

Steps To Reproduce:
1. Run any test using automated execution framework
2. Here is an example of the message that appears:
Thread[TCPDataFiller,5,main] - Plugin org.eclipse.hyades.resources.database.database_extensions, extension org.eclipse.hyades.resources.database.internal.extensions.cloudscape.CloudscapeExtension
A databaseExtension for postfix "__Cloudscape.trcadb" with higher or equal priority already exists, databaseExtension "org.eclipse.hyades.resources.database.internal.extensions.cloudscape.CloudscapeExtension@1c081c08" will be ignored.


More information:
Comment 1 Joe Toomey CLA 2007-12-31 10:30:38 EST
I have spent some time debugging this on the RPT side, and am changing components and adding some additional detail as a result of that investigation.
Comment 2 Joe Toomey CLA 2007-12-31 10:34:51 EST
I have debugged this issue, and I now understand why we're seeing this message.  The problem is actually exposed by an IBM etools plug-in which adds additional support on top of what is provided by TPTP, although I believe this is simply a defect in the extensibility mechanism in TPTP (where we incorrectly interpret this condition as an error.)

TPTP has out of the box support for storing some EMF models in Cloudscape databases (CBE log, symptom databases, correlation models, etc.)  When the IBM consuming product saves its statistical model, it goes through the normal TPTP Hierarchy infrastructure, which in turn reads in extensions of the org.eclipse.hyades.resources.database.database_extensions extension point.  Base TPTP supports Cloudscape as a database backing store for several TPTP models in the org.eclipse.hyades.resources.database plug-in through a class called org.eclipse.hyades.resources.database.internal.extensions.cloudscape.CloudscapeExtension.  This class registers its support for file extensions trcadb, corrdb and symptomdb in the following method:

	protected String[] getInternalSupportedPostfixes() {
		return new String[]{"__" + getCloudscapeExtensionName() + ".trcadb", "__" + getCloudscapeExtensionName() + ".corrdb","__" + getCloudscapeExtensionName() + ".symptomdb"};
	}

In the IBM consuming product we also ship an IBM etools plug-in that adds support for DB2, and also adds additional correlation support for Cloudscape.  That plug-in is com.ibm.etools.ac.resources.database.  Within that plug-in there is another extension of the org.eclipse.hyades.resources.database.database_extensions extension point for supporting Cloudscape databases, and that extension references the class com.ibm.etools.resources.database.extension.cloudscape.CorrelationCloudscapeExtension.  CorrelationCloudscapeExtension actually extends the TPTP class mentioned above (org.eclipse.hyades.resources.database.internal.extensions.cloudscape.CloudscapeExtension), but it overrides the createCorrelationCommand() method, presumably adding support for improved (non-time based) correlation.  

The DatabaseRegistryReader class (org.eclipse.hyades.resources.database.internal.impl.DatabaseRegistryReader), which is responsible for making a registry of classes that support the org.eclipse.hyades.resources.database extension point, has support for registering multiple classes in for a given file extension, and the class in the etools plug-in correctly declares itself as a higher priority (2) that the superclass in the base TPTP plug-in (1).  However, the DatabaseRegistryReader class incorrectly identifies this as in error condition in the readElement() method:

	if (DatabaseExtensions.getInstance().containsKey(postfix)  && ((Float)getPriorities().get(postfix)).floatValue() >= priority) {
		logError(element, "A databaseExtension for postfix \""+postfix+"\" with higher or equal priority already exists, databaseExtension \""+databaseExtensions+"\" will be ignored.");
	} else {
		DatabaseExtensions.getInstance().put(postfix, databaseExtensions);
		getPriorities().put(postfix,new Float(priority));
	}

This logError method writes these spurious error messages to the console, which is quite ugly for *nix users who routinely see all console output and may interpret this as a real error.  

Below is a stack trace that shows roughly how the consuming product gets to the offending method in DatabaseRegistryReader:

Thread [TCPDataFiller] (Suspended (breakpoint at line 80 in DatabaseRegistryReader))	
	DatabaseRegistryReader.readElement(HyadesConfigurationElement) line: 80	
	DatabaseRegistryReader(RegistryReader).internalReadElement(HyadesConfigurationElement) line: 306	
	DatabaseRegistryReader(RegistryReader).platformReadRegistry() line: 326	
	DatabaseRegistryReader(RegistryReader).readRegistry() line: 225	
	DatabaseExtensions.getInstance() line: 46	
	DBHyadesResourceExtension.getSupportedPostfixes() line: 297	
	HyadesResourceRegistryReader.readElement(HyadesConfigurationElement) line: 209	
	HyadesResourceRegistryReader(RegistryReader).internalReadElement(HyadesConfigurationElement) line: 306	
	HyadesResourceRegistryReader(RegistryReader).platformReadRegistry() line: 326	
	HyadesResourceRegistryReader(RegistryReader).readRegistry() line: 225	
	HyadesResourceExtensions.getInstance() line: 47	
	TRCAgentImpl.getDefaultEvents() line: 440	
	TRCAgentImpl.eGet(int, boolean, boolean) line: 704	
	TRCAgentImpl(BasicEObjectImpl).eGet(EStructuralFeature, boolean, boolean) line: 595	
	TRCAgentImpl(BasicEObjectImpl).eGet(EStructuralFeature, boolean) line: 587	
	HierarchyXMIResourceImpl.traverseContaintment(EObject) line: 448	
	HierarchyXMIResourceImpl.buildObjectsMap() line: 429	
	HierarchyXMIResourceImpl.doSave(OutputStream, Map) line: 411	
	HierarchyXMIResourceImpl(ResourceImpl).save(OutputStream, Map) line: 993	
	HierarchyXMIResourceImpl(ResourceImpl).save(Map) line: 881	

<...> product code <...>

	TCPDataServer$TCPDataProcessorNew.writeMessage(int, byte[]) line: 1015	
	TCPDataServer$TCPDataProcessorNew.processCurrentBuffer() line: 961	
	TCPDataServer$TCPDataProcessorNew.run() line: 706	

Comment 3 Joe Toomey CLA 2007-12-31 10:39:18 EST
Having said all that, I recommend a simple fix to org.eclipse.hyades.resources.database.internal.impl.DatabaseRegistryReader.readElement(HyadesConfigurationElement) that only emits an error message if two classes are registered for the same postfix with the same priority.  If multiple classes are registered with different priorities, then the higher priority one should win and there's no ambiguity as to which one should be used.  We shouldn't report that as an error condition.
Comment 4 Joe Toomey CLA 2007-12-31 10:40:39 EST
Marius, can you recommend an owner for this defect?  If you agree with my suggestion, we'd really like to get this fixed in 4.5.

Thanks,
--Joe
Comment 5 Paul Slauenwhite CLA 2008-01-02 08:04:07 EST
(In reply to comment #4)
> Marius, can you recommend an owner for this defect?  If you agree with my
> suggestion, we'd really like to get this fixed in 4.5.
> 
> Thanks,
> --Joe
> 

Thanks Joe.  Can you please update the hours worked in debugging this symptom?

Since this defected is related to the log/stats model, Alex would be the most likely candidate to integrate the fix. 
Comment 6 Joe Toomey CLA 2008-01-02 08:15:36 EST
Updating hours worked per Paul's request.
Comment 7 Alex Nan CLA 2008-03-13 09:39:03 EDT
I've changed the method org.eclipse.hyades.resources.database.internal.impl.DatabaseRegistryReader.readElement(HyadesConfigurationElement) to log the message only when running in model debug mode, i.e. ModelDebugger.INSTANCE.debug flag turned on. By default this flag if off.
Comment 8 Paul Slauenwhite CLA 2009-06-30 13:48:26 EDT
As of TPTP 4.6.0, TPTP is in maintenance mode and focusing on improving quality by resolving relevant enhancements/defects and increasing test coverage through test creation, automation, Build Verification Tests (BVTs), and expanded run-time execution. As part of the TPTP Bugzilla housecleaning process (see http://wiki.eclipse.org/Bugzilla_Housecleaning_Processes), this enhancement/defect is verified/closed by the Project Lead since this enhancement/defect has been resolved and unverified for more than 1 year and considered to be fixed. If this enhancement/defect is still unresolved and reproducible in the latest TPTP release (http://www.eclipse.org/tptp/home/downloads/), please re-open.
Comment 9 Paul Slauenwhite CLA 2009-06-30 14:18:58 EDT
As of TPTP 4.6.0, TPTP is in maintenance mode and focusing on improving quality by resolving relevant enhancements/defects and increasing test coverage through test creation, automation, Build Verification Tests (BVTs), and expanded run-time execution. As part of the TPTP Bugzilla housecleaning process (see http://wiki.eclipse.org/Bugzilla_Housecleaning_Processes), this enhancement/defect is verified/closed by the Project Lead since this enhancement/defect has been resolved and unverified for more than 1 year and considered to be fixed. If this enhancement/defect is still unresolved and reproducible in the latest TPTP release (http://www.eclipse.org/tptp/home/downloads/), please re-open.