* [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable [not found] <320075ff0902060702n7573aaecu9054626ee9a6991@mail.gmail.com> @ 2009-02-06 21:15 ` Nigel Magnay 2009-02-08 2:13 ` Robin Rosenberg 0 siblings, 1 reply; 6+ messages in thread From: Nigel Magnay @ 2009-02-06 21:15 UTC (permalink / raw) To: Git ML Make AnyObjectId and RemoteConfig Serializable. When using jgit as a library in other tools, it's helpful to be able to use the nice, tested bits of jgit rather than String, but need to be able to serialize them. Signed-off-by: Nigel Magnay <nigel.magnay@gmail.com> --- .../src/org/spearce/jgit/lib/AnyObjectId.java | 3 ++- .../org/spearce/jgit/transport/RemoteConfig.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java index e2f70ca..532174b 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.io.Serializable; import java.io.Writer; import java.nio.ByteBuffer; import java.util.Arrays; @@ -52,7 +53,7 @@ * with this instance can alter at any time, if this instance is modified to * represent a different object name. */ -public abstract class AnyObjectId implements Comparable { +public abstract class AnyObjectId implements Comparable, Serializable { static final int RAW_LEN = Constants.OBJECT_ID_LENGTH; static final int STR_LEN = RAW_LEN * 2; 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..7949612 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java @@ -38,6 +38,7 @@ package org.spearce.jgit.transport; +import java.io.Serializable; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collections; @@ -53,7 +54,7 @@ * describing how refs should be transferred between this repository and the * remote repository. */ -public class RemoteConfig { +public class RemoteConfig implements Serializable { private static final String SECTION = "remote"; private static final String KEY_URL = "url"; -- 1.6.0.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable 2009-02-06 21:15 ` [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable Nigel Magnay @ 2009-02-08 2:13 ` Robin Rosenberg 2009-02-08 13:26 ` Nigel Magnay 0 siblings, 1 reply; 6+ messages in thread From: Robin Rosenberg @ 2009-02-08 2:13 UTC (permalink / raw) To: Nigel Magnay; +Cc: Git ML, Shawn O. Pearce fredag 06 februari 2009 22:15:29 skrev Nigel Magnay: > Make AnyObjectId and RemoteConfig Serializable. > When using jgit as a library in other tools, it's helpful to be able > to use the nice, tested bits of jgit rather than String, but need to > be able to serialize them. A problem (big problem) with serialization is that it often leads to fragile interfaces. One might want to have precise control over the serialization so a change in the implementation doesn't affect compatibility. Serializing AnyObjectId should not depend on the implementation de jour. Second, how do we handle subclasses? But maybe leaving it this way would be our way of saying that the interface may break at any time, promise. -- robin ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable 2009-02-08 2:13 ` Robin Rosenberg @ 2009-02-08 13:26 ` Nigel Magnay 2009-02-08 19:10 ` Shawn O. Pearce 0 siblings, 1 reply; 6+ messages in thread From: Nigel Magnay @ 2009-02-08 13:26 UTC (permalink / raw) To: Robin Rosenberg; +Cc: Git ML, Shawn O. Pearce > A problem (big problem) with serialization is that it often leads to > fragile interfaces. One might want to have precise control over > the serialization so a change in the implementation doesn't affect > compatibility. Serializing AnyObjectId should not depend on the > implementation de jour. Second, how do we handle subclasses? > > But maybe leaving it this way would be our way of saying that > the interface may break at any time, promise. > Well, we can of course implement writeObject / readObject (or do so if/when compatibility breaks, and it's cared about) That's how I tend to view it anyway (may break at any time) - you can't just update a jar library to a significantly new version and expect it all to stay compatible. Also for half my use, it's not for persistence, it's for transferring over the wire to a slave process. Thinking a bit more clearly, I probably don't need AnyObjectId, just ObjectId - but I've also missed RefSpec and URIish as they're used in RemoteConfig.. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable 2009-02-08 13:26 ` Nigel Magnay @ 2009-02-08 19:10 ` Shawn O. Pearce 2009-02-08 19:45 ` Robin Rosenberg 0 siblings, 1 reply; 6+ messages in thread From: Shawn O. Pearce @ 2009-02-08 19:10 UTC (permalink / raw) To: Nigel Magnay; +Cc: Robin Rosenberg, Git ML Nigel Magnay <nigel.magnay@gmail.com> wrote: > > A problem (big problem) with serialization is that it often leads to > > fragile interfaces. One might want to have precise control over > > the serialization so a change in the implementation doesn't affect > > compatibility. Serializing AnyObjectId should not depend on the > > implementation de jour. Second, how do we handle subclasses? > > > > But maybe leaving it this way would be our way of saying that > > the interface may break at any time, promise. > > Well, we can of course implement writeObject / readObject (or do so > if/when compatibility breaks, and it's cared about) > > That's how I tend to view it anyway (may break at any time) - you > can't just update a jar library to a significantly new version and > expect it all to stay compatible. Also for half my use, it's not for > persistence, it's for transferring over the wire to a slave process. > > Thinking a bit more clearly, I probably don't need AnyObjectId, just > ObjectId - but I've also missed RefSpec and URIish as they're used in > RemoteConfig.. Here's my two cents... we can do this, but only if we implement Externalizable and do the read and write ourselves so we have a stable format. In the case of any of the types you are discussing there is an easy canonical form for them to be written on the wire, or to read back: ObjectId - the 20 byte SHA-1 RefSpec - the string form as it appears in the config file URIish - the string form as it appears in the config file RemoteConfig - a map of keys/values as it appears in the config -- Shawn. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable 2009-02-08 19:10 ` Shawn O. Pearce @ 2009-02-08 19:45 ` Robin Rosenberg 2009-02-08 19:47 ` Shawn O. Pearce 0 siblings, 1 reply; 6+ messages in thread From: Robin Rosenberg @ 2009-02-08 19:45 UTC (permalink / raw) To: Shawn O. Pearce; +Cc: Nigel Magnay, Git ML söndag 08 februari 2009 20:10:24 skrev Shawn O. Pearce: > Nigel Magnay <nigel.magnay@gmail.com> wrote: > > > A problem (big problem) with serialization is that it often leads to > > > fragile interfaces. One might want to have precise control over > > > the serialization so a change in the implementation doesn't affect > > > compatibility. Serializing AnyObjectId should not depend on the > > > implementation de jour. Second, how do we handle subclasses? > > > > > > But maybe leaving it this way would be our way of saying that > > > the interface may break at any time, promise. > > > > Well, we can of course implement writeObject / readObject (or do so > > if/when compatibility breaks, and it's cared about) > > > > That's how I tend to view it anyway (may break at any time) - you > > can't just update a jar library to a significantly new version and > > expect it all to stay compatible. Also for half my use, it's not for > > persistence, it's for transferring over the wire to a slave process. Over-the wire has the same issue. Clients and servers often run with slightly different versions. > > Thinking a bit more clearly, I probably don't need AnyObjectId, just > > ObjectId - but I've also missed RefSpec and URIish as they're used in > > RemoteConfig.. > > Here's my two cents... we can do this, but only if we implement > Externalizable and do the read and write ourselves so we have a > stable format. > In the case of any of the types you are discussing there is an easy > canonical form for them to be written on the wire, or to read back: > > ObjectId - the 20 byte SHA-1 > RefSpec - the string form as it appears in the config file > URIish - the string form as it appears in the config file with our without the password? > RemoteConfig - a map of keys/values as it appears in the config I lean toward the do it correctly side too. Don't forget a few test cases with pre-recorded serializations to verify compatibility over different versions of jgit. -- robin ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable 2009-02-08 19:45 ` Robin Rosenberg @ 2009-02-08 19:47 ` Shawn O. Pearce 0 siblings, 0 replies; 6+ messages in thread From: Shawn O. Pearce @ 2009-02-08 19:47 UTC (permalink / raw) To: Robin Rosenberg; +Cc: Nigel Magnay, Git ML Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote: > söndag 08 februari 2009 20:10:24 skrev Shawn O. Pearce: > > In the case of any of the types you are discussing there is an easy > > canonical form for them to be written on the wire, or to read back: > > > > ObjectId - the 20 byte SHA-1 > > RefSpec - the string form as it appears in the config file > > URIish - the string form as it appears in the config file > > with our without the password? With. We're serializing the object, we should store as much of the data as we have. Clients throwing this over the wire should either be careful with their connection (e.g. use SSL) or be careful with the data they are throwing (e.g. don't use URIish that has password). -- Shawn. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-08 19:49 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <320075ff0902060702n7573aaecu9054626ee9a6991@mail.gmail.com> 2009-02-06 21:15 ` [PATCH JGIT] Minor : Make ObjectId, RemoteConfig Serializable Nigel Magnay 2009-02-08 2:13 ` Robin Rosenberg 2009-02-08 13:26 ` Nigel Magnay 2009-02-08 19:10 ` Shawn O. Pearce 2009-02-08 19:45 ` Robin Rosenberg 2009-02-08 19:47 ` Shawn O. Pearce
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).