git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 5/7] FindBugs: Fix use of byte[].toString() in error messages

From
Shawn O. Pearce <spearce@spearce.org>
Date
May 4, 2009, 23:30 UTC
Message-ID
<1241479848-20687-5-git-send-email-spearce@spearce.org>
In-Reply-To
<1241479848-20687-4-git-send-email-spearce@spearce.org>

We meant to use typeString here, not encodedTypeString, as we want a human-readable string form of the object type for display into an exception message. FindBugs caught us using a byte[] here and not a string, resulting in a useless portion of the message text.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/transport/IndexPack.java  |    2 +-
 .../jgit/transport/WalkFetchConnection.java        |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java
index 7881124..b2bcbb7 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java
@@ -744,7 +744,7 @@ private void verifySafeObject(final AnyObjectId id, final int type,
 				objCheck.check(type, data);
 			} catch (CorruptObjectException e) {
 				throw new IOException("Invalid "
-						+ Constants.encodedTypeString(type) + " " + id.name()
+						+ Constants.typeString(type) + " " + id.name()
 						+ ":" + e.getMessage());
 			}
 		}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/WalkFetchConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/WalkFetchConnection.java
index 06b2c87..4d14305 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/WalkFetchConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/WalkFetchConnection.java
@@ -602,7 +602,7 @@ private void verifyLooseObject(final AnyObjectId id, final byte[] compressed)
 		if (!AnyObjectId.equals(id, idBuffer)) {
 			throw new TransportException("Incorrect hash for " + id.name()
 					+ "; computed " + idBuffer.name() + " as a "
-					+ Constants.encodedTypeString(uol.getType()) + " from "
+					+ Constants.typeString(uol.getType()) + " from "
 					+ compressed.length + " bytes.");
 		}
 		if (objCheck != null) {
@@ -610,7 +610,7 @@ private void verifyLooseObject(final AnyObjectId id, final byte[] compressed)
 				objCheck.check(uol.getType(), uol.getCachedBytes());
 			} catch (CorruptObjectException e) {
 				throw new TransportException("Invalid "
-						+ Constants.encodedTypeString(uol.getType()) + " "
+						+ Constants.typeString(uol.getType()) + " "
 						+ id.name() + ":" + e.getMessage());
 			}
 		}
-- 
1.6.3.rc4.206.g03e16
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 5 of 8 in “Fix FindBugs exclude filter to work on UNIX platforms”
  1. 1/7 Fix FindBugs exclude filter to work on UNIX platformsShawn O. Pearce, May 4, 2009
  2. 2/7 Silence FindBugs "dubious use of GC" in PackFile.mmapShawn O. Pearce, May 4, 2009
  3. 3/7 Fix FindBugs String == is bad formShawn O. Pearce, May 4, 2009
  4. 4/7 Fix FindBugs load known null valueShawn O. Pearce, May 4, 2009
  5. 5/7 FindBugs: Fix use of byte[].toString() in error messagesShawn O. Pearce, May 4, 2009
  6. 6/7 Make TransportLocal.StreamRewritingThread staticShawn O. Pearce, May 4, 2009
  7. 7/7 FindBugs: Disable clone() idiom testsShawn O. Pearce, May 4, 2009
  8. Sohn, MatthiasMay 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.