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

Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 18, 2009, 16:30 UTC
Message-ID
<20090218163002.GB22848@spearce.org>
In-Reply-To
<320075ff0902161212s1980cd70r8cdc4c21550333ee@mail.gmail.com>
Nigel Magnay <nigel.magnay@gmail.com> wrote:
> +public class ObjectId extends AnyObjectId implements Serializable {
We should define our own serialVersionUID:
  private static final long serialVersionUID = 1L;
is good enough to make Java happy.
Show 7 quoted lines
> @@ -269,4 +273,20 @@ protected ObjectId(final AnyObjectId src) {
>  	public ObjectId toObjectId() {
>  		return this;
>  	}
> +
> +	private void writeObject(ObjectOutputStream os)  throws IOException {
> +	private void readObject(ObjectInputStream ois)  throws IOException {
Minor nit: Only 1 space between ) and throws, please.
Show 11 quoted lines
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java
> b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java
> index 5bbf664..899f73f 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java
> @@ -53,7 +57,7 @@
>   * describing how refs should be transferred between this repository and the
>   * remote repository.
>   */
> -public class RemoteConfig {
> +public class RemoteConfig implements Serializable {
Please set a serialVersionUID.
Show 17 quoted lines
> @@ -382,4 +386,77 @@ public TagOpt getTagOpt() {
>  	public void setTagOpt(final TagOpt option) {
>  		tagopt = option != null ? option : TagOpt.AUTO_FOLLOW;
>  	}
> +	
> +	private void writeObject(ObjectOutputStream os) throws IOException {
> +
> +	    // Name
> +	    os.writeUTF(name);
> +	
> +	    // Key, Value pairs
> +	    for (URIish uri : uris) {
> +            os.writeUTF(KEY_URL);
> +            os.writeUTF(uri.toPrivateString());
> +        }
> +
> +        for (RefSpec refspec : fetch) {

There is some sort of whitespace damage here, the second for loop is not lined up at the same starting column as the first for loop. My guess is, you have tabs in here. We only indent with spaces.

Show 8 quoted lines
> +            os.writeUTF(KEY_FETCH);
> +            os.writeUTF(refspec.toString());
> +        }
> +
> +        for (RefSpec refspec : push) {
> +        	os.writeUTF(KEY_PUSH);
> +            os.writeUTF(refspec.toString());
> +        }

Should we maybe allow RefSpec to serialize itself with os.writeObject() rather than using writeUTF() directly?

FWIW, I did find this new implementation to be much easier to read. Thanks.

-- 
Shawn.
Previous: Johannes SchindelinNext: Robin Rosenberg
Message 3 of 10 in “1/2 : (reworked) Externalizable/Serializable Items”
  1. 1/2 : (reworked) Externalizable/Serializable ItemsNigel Magnay, Feb 16, 2009
  2. Johannes SchindelinFeb 16, 2009
  3. Shawn O. PearceFeb 18, 2009
  4. Robin RosenbergFeb 18, 2009
  5. Shawn O. PearceFeb 18, 2009
  6. Sverre RabbelierFeb 18, 2009
  7. Robin RosenbergFeb 18, 2009
  8. Shawn O. PearceFeb 18, 2009
  9. Nigel MagnayFeb 20, 2009
  10. Shawn O. PearceFeb 20, 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.