Skip to content

Commit

Permalink
Fixed NPE during read-only start-up, gitignore and some more cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
janste63 committed Apr 13, 2016
1 parent 2968435 commit ff725ef
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
*~
.classpath
.project
ant/classes/
ant/lib/
eclipse_bin/
osgi/bundles/remotefw/doc/client.xargs
osgi/bundles/remotefw/doc/server.xargs
osgi/bundles_examples/cpa/init.xargs
osgi/bundles_opt/classpatcher/resources/asm-3.2.jar
osgi/bundles_test/regression_tests/component_test/resources/
osgi/bundles_test/regression_tests/condpermadmin_test/resources/
osgi/bundles_test/regression_tests/endurance_test/resources/
osgi/bundles_test/regression_tests/extension_test/resources/
osgi/bundles_test/regression_tests/framework_test/resources/*.jar
osgi/bundles_test/regression_tests/out/
osgi/bundles_test/regression_tests/restart_test/resources/
osgi/bundles_test/regression_tests/servicetracker_test/resources/
osgi/bundles_test/regression_tests/startlevel_test/resources/
osgi/dex_jars/
osgi/framework.jar
osgi/framework/resources/exports
osgi/framework/resources/release
osgi/framework/resources/tstamp
osgi/framework/resources/version
osgi/fwdir/
osgi/headless.xargs
osgi/init-tests.xargs
osgi/init.xargs
osgi/jars/
osgi/junit_grunt/
osgi/minimal.xargs
osgi/out/
osgi/remote-init.xargs
osgi/test-restart1.xargs
osgi/test-restart2.xargs
osgi/test_jars/
out/
3 changes: 3 additions & 0 deletions osgi/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@
<delete dir="${root.out.dir}"/>
<delete dir="jars"/>
<delete dir="dex_jars"/>
<delete dir="test_jars"/>
<delete dir="${ant.dir}/classes"/>
<delete file="headless.xargs"/>
<delete file="minimal.xargs"/>
Expand All @@ -483,6 +484,8 @@
<delete file="init_Windows2000.xargs"/>
<delete file="init_WindowsXP.xargs"/>
<delete file="init-tests.xargs"/>
<delete file="test-restart1.xargs"/>
<delete file="test-restart2.xargs"/>
<delete file="${exported.file}"/>
<delete file="${sources.file}"/>
<delete dir="${junit.out.dir}"/>
Expand Down
2 changes: 1 addition & 1 deletion osgi/framework/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<property name="frameworkdoc_template"
location="${ant.dir}/html_template/frameworkdoc.html"/>

<property name="fw.impl.version" value="7.2.2"/>
<property name="fw.impl.version" value="7.2.3"/>

<property name="jarfile"
location="${topdir}/${ant.project.name}.jar"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2015, KNOPFLERFISH project
* Copyright (c) 2003-2016, KNOPFLERFISH project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -1222,6 +1222,11 @@ private void checkManifest() {
Util.parseManifestHeader(Constants.IMPORT_PACKAGE,
a.getValue(Constants.IMPORT_PACKAGE), false, true,
false);
if (ba.storage.isReadOnly() && needUnpack(a)) {
throw new IllegalArgumentException("Framework is in read-only mode, we can not " +
"install bundles that needs to be downloaded " +
"(e.g. has native code or an internal Bundle-ClassPath)");
}
// NYI, more checks?
}

Expand Down Expand Up @@ -1321,7 +1326,7 @@ private File getSubFile(Archive archive, String path) {
* @param is InputStream to read from.
*/
private void loadFile(File output, InputStream is) throws IOException {
if (ba.storage.isReadOnly()) {
if (output != null && ba.storage.isReadOnly()) {
throw new IOException("Bundle storage is read-only, unable to save: " + output);
}
OutputStream os = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2015, KNOPFLERFISH project
* Copyright (c) 2003-2016, KNOPFLERFISH project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -143,6 +143,14 @@ public class BundleStorageImpl implements BundleStorage {
public BundleStorageImpl(FrameworkContext framework) {
this.framework = framework;
initProps(framework.props);
if (isReadOnly()) {
if (alwaysUnpack) {
throw new RuntimeException("Property '" + ALWAYS_UNPACK_PROP + "' must be false when we are in read only mode!");
}
if (unpack) {
throw new RuntimeException("Property '" + UNPACK_PROP + "' must be false when we are in read only mode!");
}
}
// See if we have a storage directory
bundlesDir = Util.getFileStorage(framework, "bs", !isReadOnly());
if (bundlesDir == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2014, KNOPFLERFISH project
* Copyright (c) 2008-2016, KNOPFLERFISH project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -86,7 +86,7 @@ class ConditionalPermissionInfoStorage {
if (condPermDir == null) {
System.err.println("Property org.osgi.framework.dir not set," +
"conditional permission info will not be saved between sessions");
} else {
} else if (condPermDir.isDirectory()) {
load();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2014, KNOPFLERFISH project
* Copyright (c) 2006-2016, KNOPFLERFISH project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -90,7 +90,7 @@ public PermissionInfoStorage(FrameworkContext ctx) {
if (permDir == null) {
System.err.println("Property org.osgi.framework.dir not set," +
"permission data will not be saved between sessions");
} else {
} else if (permDir.isDirectory()) {
load();
}
}
Expand Down
5 changes: 5 additions & 0 deletions release_notes.in.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ <h2 class="filled">Knopflerfish Framework - OSGi Core Specification</h2>
<div class="release_notes">

<div class="note_group">
<div class="note_name">Framework 7.2.3</div>
<div class="note_item">
Fixed so that we can use security manager without persistent storage
(e.g. read-only mode).
</div>
<div class="note_name">Framework 7.2.2</div>
<div class="note_item">
Added missing check in resolver, caused the resolver under certain conditions
Expand Down

1 comment on commit ff725ef

@janste63
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #1.

Please sign in to comment.