Hello,
When I use onepoint project and choose to save password, the applet start failed. Then I check java console and found exception below:
java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at onepoint.util.XCookieManager.loadCookies(XCookieManager.java:245)
at onepoint.util.XCookieManager.<init>(XCookieManager.java:64)
at onepoint.service.XBinaryClient.<init>(XBinaryClient.java:60)
at onepoint.express.applet.XExpressApplet.init(XExpressApplet.java:149)
at onepoint.project.applet.OpOpenApplet.init(OpOpenApplet.java:279)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Then I get XCookieManager.java at here and found there maybe a bug cause this exception.
You call more than 6 times of nextToken(), if UnsupportedOperationException is thrown:
I update the method below base on svn version 220. please check it.
/**
* Loads the persisted cookies
*
* @throws IOException if the loading of cookies fails
*/
private void loadCookies()
throws IOException {
LineNumberReader reader = null;
try {
reader = new LineNumberReader(new FileReader(cookieFile));
String line;
while ((line = reader.readLine()) != null) {
for (StringTokenizer st = new StringTokenizer(line, DELIM); st.hasMoreTokens();) {
if (st.countTokens() != 6) {
// it should be 6 fields, otherwise we skip the entry
continue;
}
Cookie jcookie = new Cookie(st.nextToken(), st.nextToken(), st.nextToken(), st.nextToken());
jcookie.setVersion(st.nextToken());
Date expires = new Date(Long.decode(st.nextToken()).longValue());
try {
jcookie.setExpires(expires);
}
catch (UnsupportedOperationException exc) {
Date now = new Date();
int maxage = (int)((now.getTime() - expires.getTime()) / 1000);
jcookie.setMaxAge(maxage);
}
if (jcookie.hasExpired()) {
continue;
}
cookies.add(jcookie);
}
}
}
finally {
if (reader != null) {
reader.close();
}
}
}
maybe another bug:
int maxage = (int)((now.getTime() - expires.getTime()) /1000);
should be
int maxage = (int)((expires.getTime() - now.getTime()) /1000);