Mercurial > jhg
diff src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 334:15e1961719f2
Investigate sporadic BufferUnderflowException
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 09 Nov 2011 05:22:26 +0100 |
parents | 4c7e3ba67213 |
children | f377f833b780 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Wed Nov 09 04:56:36 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Wed Nov 09 05:22:26 2011 +0100 @@ -415,8 +415,15 @@ if (buffer.position() > 5) { buffer.position(buffer.position() - 5); } - buffer.get(xx, 0, min(xx.length, i)); - repo.getContext().getLog().debug(getClass(), "expected >>%s<< but got >>%s<<", new String(data, max(0, x - 4), min(data.length - x, 20)), new String(xx)); + buffer.get(xx, 0, min(xx.length, i-1 /*-1 for the one potentially read at buffer.get in if() */)); + String exp; + if (x < data.length) { + exp = new String(data, max(0, x - 4), min(data.length - x, 20)); + } else { + int offset = max(0, x - 4); + exp = new String(data, offset, min(data.length - offset, 20)); + } + repo.getContext().getLog().debug(getClass(), "expected >>%s<< but got >>%s<<", exp, new String(xx)); } sameSoFar = false; break;