Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/FilterDataAccess.java @ 397:5e95b0da26f2 smartgit3
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 23 Feb 2012 15:31:57 +0100 |
parents | facfd8518367 |
children | 6c22bdc0bdfd |
comparison
equal
deleted
inserted
replaced
393:728708de3597 | 397:5e95b0da26f2 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 TMate Software Ltd | 2 * Copyright (c) 2011-2012 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
86 } | 86 } |
87 | 87 |
88 @Override | 88 @Override |
89 public byte readByte() throws IOException { | 89 public byte readByte() throws IOException { |
90 if (count <= 0) { | 90 if (count <= 0) { |
91 throw new IllegalArgumentException("Underflow"); // XXX be descriptive | 91 throw new IOException(String.format("Underflow. Bytes left: %d. FilterDA[offset: %d, length: %d]", count, offset, length)); |
92 } | 92 } |
93 if (count == length) { | 93 if (count == length) { |
94 dataAccess.seek(offset); | 94 dataAccess.seek(offset); |
95 } | 95 } |
96 count--; | 96 count--; |
101 public void readBytes(byte[] b, int off, int len) throws IOException { | 101 public void readBytes(byte[] b, int off, int len) throws IOException { |
102 if (len == 0) { | 102 if (len == 0) { |
103 return; | 103 return; |
104 } | 104 } |
105 if (count <= 0 || len > count) { | 105 if (count <= 0 || len > count) { |
106 throw new IllegalArgumentException(String.format("Underflow. Bytes left: %d, asked to read %d", count, len)); | 106 throw new IOException(String.format("Underflow. Bytes left: %d, asked to read %d. FilterDA[offset: %d, length: %d]", count, len, offset, length)); |
107 } | 107 } |
108 if (count == length) { | 108 if (count == length) { |
109 dataAccess.seek(offset); | 109 dataAccess.seek(offset); |
110 } | 110 } |
111 dataAccess.readBytes(b, off, len); | 111 dataAccess.readBytes(b, off, len); |