Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.8k views
in Java FTP by (140 points)
Stop me if you've heard this one before.

Working in an AI product called Blaze, from FairIsaac. All XML and Java. Not terribly amenable to documentation, hundreds of thousands of itty bitty rules implemented in XML. Connecting to IBM mainframe OMVS ftpd

Previous developers took to documenting things in the file name. Whole sentences. Never saw anything like it.

Ran afoul of the private final static int MAX_FIELDS = 20;

Manifested very oddly, I was recursing down the tree, and my code started manifesting java.lang.IllegalMonitorStateException: current thread not owner. Started synchronizing things, but couldn't figure out why iit was always blowing on the same file. Then I looked at the file name in the debugger, and there it was, big, dumb and ugly. Think of this monster

C:\ftphome\1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23.txt

Still don't know why it didn't throw the ArrayOutOfBounds exception. Maybe it was the recursion.

Here's the code which caught it: feel free to use the pattern

http://www.kiebalam.com/enterprisedt/FTPSession.java

Here's the short haul patch:

http://www.kiebalam.com/enterprisedt/FTPFileParser.java

Maybe someone can write me back if this has been caught, maybe let me have a copy of the Pro secure FTP software, heh

/**
* Splits string consisting of fields separated by
* whitespace into an array of strings. Yes, we could
* use String.split() but this would restrict us to 1.4+
*
* Patched by Dan Weese 2005/07/07
* concatenate all ugly long files into last string
* danweese@gmail.com
*
* @param str string to split
* @return array of fields
*/
protected String[] split(String str) {
String[] fields = new String[MAX_FIELDS];
int pos = 0;
StringBuffer field = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if (pos >= MAX_FIELDS - 1 ) {
field.append(ch);
} else {
if (!Character.isWhitespace(ch))
field.append(ch);
else {
if (field.length() > 0) {
fields[pos++] = field.toString();
field.setLength(0);
}
}
}
}
// pick up last field
if (field.length() > 0) {
fields[pos++] = field.toString();
}
String[] result = new String[pos];
System.arraycopy(fields, 0, result, 0, pos);
return result;
}

1 Answer

0 votes
by (162k points)
Curiously, someone else has just uncovered this problem as well. Thanks for posting a fix, we will fix this in the next release.

Stop me if you've heard this one before.

Working in an AI product called Blaze, from FairIsaac. All XML and Java. Not terribly amenable to documentation, hundreds of thousands of itty bitty rules implemented in XML. Connecting to IBM mainframe OMVS ftpd

Previous developers took to documenting things in the file name. Whole sentences. Never saw anything like it.

Ran afoul of the private final static int MAX_FIELDS = 20;

Categories

...