Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 198941 Details for
Bug 346804
[metatype] Error parsing xml with empty <MetaData/> element
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed patch
350201_20010630-1735.txt (text/plain), 14.34 KB, created by
John Ross
on 2011-06-30 18:52:34 EDT
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
John Ross
Created:
2011-06-30 18:52:34 EDT
Size:
14.34 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.metatype >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.metatype/META-INF/MANIFEST.MF,v >retrieving revision 1.12 >diff -u -r1.12 MANIFEST.MF >--- META-INF/MANIFEST.MF 18 Mar 2011 19:37:21 -0000 1.12 >+++ META-INF/MANIFEST.MF 30 Jun 2011 22:35:55 -0000 >@@ -1,6 +1,6 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %bundleName >-Bundle-Version: 1.1.0.qualifier >+Bundle-Version: 1.1.100.qualifier > Bundle-SymbolicName: org.eclipse.equinox.metatype > Bundle-Activator: org.eclipse.equinox.metatype.Activator > Import-Package: javax.xml.parsers, >Index: src/org/eclipse/equinox/metatype/DataParser.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/DataParser.java,v >retrieving revision 1.18 >diff -u -r1.18 DataParser.java >--- src/org/eclipse/equinox/metatype/DataParser.java 6 Apr 2011 16:32:54 -0000 1.18 >+++ src/org/eclipse/equinox/metatype/DataParser.java 30 Jun 2011 22:35:55 -0000 >@@ -100,27 +100,15 @@ > /* > * Main method to parse specific MetaData file. > */ >- public Collection<Designate> doParse() { >- >- try { >- SAXParser saxParser = _dp_parserFactory.newSAXParser(); >- _dp_xmlReader = saxParser.getXMLReader(); >- _dp_xmlReader.setContentHandler(new RootHandler()); >- _dp_xmlReader.setErrorHandler(new MyErrorHandler(System.err)); >- InputStream is = _dp_url.openStream(); >- InputSource isource = new InputSource(is); >- logger.log(LogService.LOG_DEBUG, "Starting to parse " + _dp_url); //$NON-NLS-1$ >- _dp_xmlReader.parse(isource); >- } catch (ParserConfigurationException pce) { >- pce.printStackTrace(); >- return null; >- } catch (SAXException saxe) { >- saxe.printStackTrace(); >- return null; >- } catch (IOException ioe) { >- ioe.printStackTrace(); >- return null; >- } >+ public Collection<Designate> doParse() throws IOException, ParserConfigurationException, SAXException { >+ SAXParser saxParser = _dp_parserFactory.newSAXParser(); >+ _dp_xmlReader = saxParser.getXMLReader(); >+ _dp_xmlReader.setContentHandler(new RootHandler()); >+ _dp_xmlReader.setErrorHandler(new MyErrorHandler(System.err)); >+ InputStream is = _dp_url.openStream(); >+ InputSource isource = new InputSource(is); >+ logger.log(LogService.LOG_DEBUG, "Starting to parse " + _dp_url); //$NON-NLS-1$ >+ _dp_xmlReader.parse(isource); > return designates; > } > >@@ -279,7 +267,7 @@ > if (_dp_designateHandlers.size() == 0) { > // Schema defines at least one DESIGNATE is required. > _isParsedDataValid = false; >- logger.log(LogService.LOG_ERROR, "DataParser.finished() " + NLS.bind(MetaTypeMsg.MISSING_ELEMENT, DESIGNATE)); //$NON-NLS-1$ >+ logger.log(LogService.LOG_WARNING, "DataParser.finished() " + NLS.bind(MetaTypeMsg.MISSING_ELEMENT, DESIGNATE)); //$NON-NLS-1$ > return; > } > Enumeration<DesignateHandler> designateHandlerKeys = _dp_designateHandlers.elements(); >@@ -460,6 +448,11 @@ > } > > String ad_type_val = atts.getValue(TYPE); >+ if (ad_type_val == null) { >+ _isParsedDataValid = false; >+ logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, TYPE, name)); //$NON-NLS-1$ >+ return; >+ } > if (ad_type_val.equalsIgnoreCase(STRING)) { > _dataType = AttributeDefinition.STRING; > } else if (ad_type_val.equalsIgnoreCase(LONG)) { >@@ -482,9 +475,8 @@ > _dataType = AttributeDefinition.PASSWORD; > } else { > _isParsedDataValid = false; >- logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, TYPE, name)); //$NON-NLS-1$ >+ logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.INVALID_TYPE, new Object[] {ad_type_val, _dp_url, _dp_bundle.getBundleId()})); //$NON-NLS-1$ > return; >- > } > > String ad_cardinality_str = atts.getValue(CARDINALITY); >Index: src/org/eclipse/equinox/metatype/ExternalMessages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ExternalMessages.properties,v >retrieving revision 1.7 >diff -u -r1.7 ExternalMessages.properties >--- src/org/eclipse/equinox/metatype/ExternalMessages.properties 6 Apr 2011 16:32:54 -0000 1.7 >+++ src/org/eclipse/equinox/metatype/ExternalMessages.properties 30 Jun 2011 22:35:55 -0000 >@@ -14,6 +14,7 @@ > UNEXPECTED_ELEMENT=Unexpected element {0}. > UNEXPECTED_TEXT=Unexpected text {0}. > MISSING_ATTRIBUTE=Missing attribute {0} in tag {1}. >+INVALID_TYPE=Invalid attribute definition type {0} in metadata XML at {1} for bundle ID {2}. > MISSING_DESIGNATE_PID_AND_FACTORYPID=A <Designate> element must specify either the 'pid' or 'factoryPid' attribute. > OCD_ID_NOT_FOUND=Object Class Definition ID not found {0}. > MISSING_ELEMENT=Missing element {0} (Reference ID = {1}. >@@ -32,4 +33,5 @@ > ASK_INVALID_LOCALE=OCD(ID=\"{0}\") cannot support this locale \"{1}\". > MISSING_REQUIRED_PARAMETER=Missing required parameter: {0} > TOKENIZER_GOT_INVALID_DATA=The Tokenizer got invalid data. >-INVALID_PID_METATYPE_PROVIDER_IGNORED=Bundle {0} with ID {1} provided a MetaTypeProvider with an invalid property. Property {2} with value {3} was not of the expected type (String, String[], or Collection<String>) and will be ignored. >\ No newline at end of file >+INVALID_PID_METATYPE_PROVIDER_IGNORED=Bundle {0} with ID {1} provided a MetaTypeProvider with an invalid property. Property {2} with value {3} was not of the expected type (String, String[], or Collection<String>) and will be ignored. >+METADATA_PARSE_ERROR=Unable to parse metadata XML at {0} for bundle ID {1}. >\ No newline at end of file >Index: src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java,v >retrieving revision 1.6 >diff -u -r1.6 MetaTypeInformationImpl.java >--- src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java 18 Oct 2010 15:26:20 -0000 1.6 >+++ src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java 30 Jun 2011 22:35:55 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2010 IBM Corporation and others. >+ * Copyright (c) 2005, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -32,7 +32,7 @@ > /** > * Constructor of class MetaTypeInformationImpl. > */ >- MetaTypeInformationImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) throws java.io.IOException { >+ MetaTypeInformationImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) { > super(bundle, parserFactory, logger); > } > >Index: src/org/eclipse/equinox/metatype/MetaTypeMsg.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeMsg.java,v >retrieving revision 1.7 >diff -u -r1.7 MetaTypeMsg.java >--- src/org/eclipse/equinox/metatype/MetaTypeMsg.java 6 Apr 2011 16:32:54 -0000 1.7 >+++ src/org/eclipse/equinox/metatype/MetaTypeMsg.java 30 Jun 2011 22:35:55 -0000 >@@ -16,14 +16,13 @@ > private static final String BUNDLE_NAME = "org.eclipse.equinox.metatype.ExternalMessages"; //$NON-NLS-1$ > > public static String SERVICE_DESCRIPTION; >- > public static String UNEXPECTED_ELEMENT; > public static String UNEXPECTED_TEXT; > public static String MISSING_ATTRIBUTE; >+ public static String INVALID_TYPE; > public static String MISSING_DESIGNATE_PID_AND_FACTORYPID; > public static String OCD_ID_NOT_FOUND; > public static String MISSING_ELEMENT; >- > public static String EXCEPTION_MESSAGE; > public static String NULL_IS_INVALID; > public static String VALUE_OUT_OF_RANGE; >@@ -33,14 +32,12 @@ > public static String INCONSISTENT_OPTIONS; > public static String INVALID_OPTIONS; > public static String INVALID_DEFAULTS; >- > public static String METADATA_NOT_FOUND; > public static String ASK_INVALID_LOCALE; >- > public static String MISSING_REQUIRED_PARAMETER; >- > public static String TOKENIZER_GOT_INVALID_DATA; > public static String INVALID_PID_METATYPE_PROVIDER_IGNORED; >+ public static String METADATA_PARSE_ERROR; > > static { > // initialize resource bundles >Index: src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java,v >retrieving revision 1.12 >diff -u -r1.12 MetaTypeProviderImpl.java >--- src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java 25 Mar 2011 14:06:23 -0000 1.12 >+++ src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java 30 Jun 2011 22:35:55 -0000 >@@ -49,7 +49,7 @@ > /** > * Constructor of class MetaTypeProviderImpl. > */ >- MetaTypeProviderImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) throws IOException { >+ MetaTypeProviderImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) { > > this._bundle = bundle; > this.logger = logger; >@@ -83,7 +83,7 @@ > * @return void > * @throws IOException If there are errors accessing the metadata.xml file > */ >- private boolean readMetaFiles(Bundle bundle, SAXParserFactory parserFactory) throws IOException { >+ private boolean readMetaFiles(Bundle bundle, SAXParserFactory parserFactory) { > BundleWiring wiring = bundle.adapt(BundleWiring.class); > if (wiring == null) > return false; >@@ -95,16 +95,18 @@ > DataParser parser = new DataParser(bundle, entry, parserFactory, logger); > try { > Collection<Designate> designates = parser.doParse(); >- if (!designates.isEmpty()) >+ if (!designates.isEmpty()) { > result = true; >+ } > for (Designate designate : designates) { >- if (designate.isFactory()) >+ if (designate.isFactory()) { > _allFPidOCDs.put(designate.getFactoryPid(), designate.getObjectClassDefinition()); >- else >+ } else { > _allPidOCDs.put(designate.getPid(), designate.getObjectClassDefinition()); >+ } > } > } catch (Exception e) { >- // ignore >+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.METADATA_PARSE_ERROR, new Object[] {entry, bundle.getBundleId()}), e); > } > } > return result; >Index: src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java,v >retrieving revision 1.6 >diff -u -r1.6 MetaTypeServiceImpl.java >--- src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java 25 Oct 2010 18:04:37 -0000 1.6 >+++ src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java 30 Jun 2011 22:35:55 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2010 IBM Corporation and others. >+ * Copyright (c) 2005, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,10 +10,11 @@ > *******************************************************************************/ > package org.eclipse.equinox.metatype; > >-import java.io.IOException; >-import java.security.*; >+import java.security.AccessController; >+import java.security.PrivilegedExceptionAction; > import java.util.Hashtable; > import javax.xml.parsers.SAXParserFactory; >+import org.eclipse.osgi.util.NLS; > import org.osgi.framework.*; > import org.osgi.service.log.LogService; > import org.osgi.service.metatype.MetaTypeInformation; >@@ -46,33 +47,24 @@ > * @see org.osgi.service.metatype.MetaTypeService#getMetaTypeInformation(org.osgi.framework.Bundle) > */ > public MetaTypeInformation getMetaTypeInformation(Bundle bundle) { >- >- MetaTypeInformation mti; >- try { >- mti = getMetaTypeProvider(bundle); >- } catch (IOException e) { >- logger.log(LogService.LOG_ERROR, "IOException in MetaTypeInformation:getMetaTypeInformation(Bundle bundle)"); //$NON-NLS-1$ >- e.printStackTrace(); >- mti = null; >- } >- return mti; >+ return getMetaTypeProvider(bundle); > } > > /** > * Internal Method - to get MetaTypeProvider object. > */ >- private MetaTypeInformation getMetaTypeProvider(final Bundle b) throws java.io.IOException { >- >+ private MetaTypeInformation getMetaTypeProvider(final Bundle b) { >+ final LogService loggerTemp = this.logger; >+ final ServiceTracker<Object, Object> tracker = this.metaTypeProviderTracker; > try { > Long bID = new Long(b.getBundleId()); > synchronized (_mtps) { > if (_mtps.containsKey(bID)) > return _mtps.get(bID); > // Avoid synthetic accessor method warnings. >- final LogService loggerTemp = this.logger; >- final ServiceTracker<Object, Object> tracker = this.metaTypeProviderTracker; >+ > MetaTypeInformation mti = AccessController.doPrivileged(new PrivilegedExceptionAction<MetaTypeInformation>() { >- public MetaTypeInformation run() throws IOException { >+ public MetaTypeInformation run() { > MetaTypeInformationImpl impl = new MetaTypeInformationImpl(b, _parserFactory, loggerTemp); > if (!impl._isThereMeta) > return new MetaTypeProviderTracker(b, loggerTemp, tracker); >@@ -82,8 +74,9 @@ > _mtps.put(bID, mti); > return mti; > } >- } catch (PrivilegedActionException pae) { >- throw (IOException) pae.getException(); >+ } catch (Exception e) { >+ logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.EXCEPTION_MESSAGE, e.getMessage()), e); >+ return new MetaTypeProviderTracker(b, loggerTemp, tracker); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 346804
: 198941