diff src/org/tmatesoft/hg/internal/DataAccess.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 b413b16d10a5
children fdc1db8f7f61
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/DataAccess.java	Tue Feb 21 19:18:40 2012 +0100
+++ b/src/org/tmatesoft/hg/internal/DataAccess.java	Thu Feb 23 15:31:57 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2011 TMate Software Ltd
+ * Copyright (c) 2010-2012 TMate Software Ltd
  *  
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -46,11 +46,18 @@
 	}
 	// absolute positioning
 	public void seek(int offset) throws IOException {
-		throw new UnsupportedOperationException();
+		if (offset == 0) {
+			// perfectly OK for the "empty slice" instance
+			return;
+		}
+		throw new IOException(String.format("No data, can't seek %d bytes", offset));
 	}
 	// relative positioning
 	public void skip(int bytes) throws IOException {
-		throw new UnsupportedOperationException();
+		if (bytes == 0) {
+			return;
+		}
+		throw new IOException(String.format("No data, can't skip %d bytes", bytes));
 	}
 	// shall be called once this object no longer needed
 	public void done() {
@@ -69,7 +76,10 @@
 		return ((long) i1) << 32 | ((long) i2 & 0xFFFFFFFFl);
 	}
 	public void readBytes(byte[] buf, int offset, int length) throws IOException {
-		throw new UnsupportedOperationException();
+		if (length == 0) {
+			return;
+		}
+		throw new IOException(String.format("No data, can't read %d bytes", length));
 	}
 	// reads bytes into ByteBuffer, up to its limit or total data length, whichever smaller
 	// FIXME perhaps, in DataAccess paradigm (when we read known number of bytes, we shall pass specific byte count to read)