Hi all!
I just submitted this patch that fixes a problem in our System.getenv()
method.
It's possible to have variable in the form of:
key=value=value=value
like (from my env list):
XDM_MANAGED=method=classic
cheers,
Mario
2008-09-16 Mario Torre <[EMAIL PROTECTED]>
* java/lang/System.java (getenv): Fix env entries of the form
key=value=value=value not parsed correctly.
--
Mario Torre, Software Developer, http://www.jroller.com/neugens/
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com * Tel: +49-721-663 968-53
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF
USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
Geschäftsführer: Dr. James J. Hunt
Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0
#P classpath
Index: java/lang/System.java
===================================================================
RCS file: /sources/classpath/classpath/java/lang/System.java,v
retrieving revision 1.62
diff -u -r1.62 System.java
--- java/lang/System.java 7 Jan 2008 21:11:24 -0000 1.62
+++ java/lang/System.java 16 Sep 2008 19:26:17 -0000
@@ -546,20 +546,28 @@
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("getenv.*"));
+
if (environmentMap == null)
{
- List<String> environ = (List<String>)VMSystem.environ();
- Map<String,String> variables = new EnvironmentMap();
- for (String pair : environ)
- {
- String[] parts = pair.split("=");
- if (parts.length == 2)
- variables.put(parts[0], parts[1]);
- else
- variables.put(parts[0], "");
- }
- environmentMap = Collections.unmodifiableMap(variables);
+ Map<String, String> _map = new HashMap();
+ List<String> environ = (List<String>)VMSystem.environ();
+ for (String envEntry : environ)
+ {
+ // avoid broken and null entries
+ if (envEntry != null && !envEntry.endsWith("="))
+ {
+ // it's perfectly legal that some entries may be in the form
+ // key=value=value=value
+ int equalSignIndex = envEntry.indexOf('=');
+ String key = envEntry.substring(0, equalSignIndex);
+ String value = envEntry.substring(equalSignIndex + 1);
+ _map.put(key, value);
+ }
+ }
+
+ environmentMap = Collections.unmodifiableMap(_map);
}
+
return environmentMap;
}