Bug 354388 - NPE in FeatureInputContext#synchronizeModel
Added null check for IDocument argument
Change-Id: Ifa28bf0dfce1e3d39bc8aad8be459757609927d7
Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/feature/FeatureInputContext.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/feature/FeatureInputContext.java
index 532c5da..bbd6661 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/feature/FeatureInputContext.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/feature/FeatureInputContext.java
@@ -135,21 +135,17 @@
@Override
protected boolean synchronizeModel(IDocument doc) {
+ if (doc == null) {
+ return false;
+ }
IFeatureModel model = (IFeatureModel) getModel();
-
- boolean cleanModel = true;
String text = doc.get();
- InputStream stream = new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8));
- try {
+ try (InputStream stream = new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8))) {
model.reload(stream, false);
- } catch (CoreException e) {
- cleanModel = false;
+ } catch (CoreException | IOException e) {
+ return false;
}
- try {
- stream.close();
- } catch (IOException e) {
- }
- return cleanModel;
+ return true;
}
@Override