Hey Ben,

Benjamin Bentmann wrote:
Hi Oleg,

Author: ogusakov
Date: Mon Dec 15 16:04:14 2008
New Revision: 726880

URL: http://svn.apache.org/viewvc?rev=726880&view=rev
Log:
[MERCURY-56] verification configuration for mercury ant tasks done, PGP unit test works on osx. Need test keyrings for other platforms.


Modified: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java?rev=726880&r1=726879&r2=726880&view=diff ============================================================================== --- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java (original) +++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java Mon Dec 15 16:04:14 2008
@@ -593,35 +595,35 @@
   public static void main( String[] args )
   throws IOException, StreamObserverException
   {

It looks odd for a utility class to have main() method. If it serves a production purpose, wouldn't it be better to move the main() out into a dedicated class, say in the default package with a descriptive name for easy invocation from CLI? If it's only for testing, src/main/java is definitively the wrong place.

Maybe ...
Likewise, RepositoryUpdateIntervalPolicy from the mercury-repo-api contains a main() method which pretty much looks like test code that should be deleted/moved out.
This one - agree, I missed it when cleaning

//---------------------------------------------------------------------------------------------------------------
+  public static InputStream toStream( String resource )
+  throws MalformedURLException, IOException
+  {
+    if( Util.isEmpty( resource ) )
+      return null;
+    +    if( resource.startsWith( "file://" )
+        || resource.startsWith( "http://"; )
+    )
+      return new URL(resource).openStream();
+
+    return new FileInputStream( new File(resource) );
+  }

RFC 2396 [0], section 3.1, "Scheme Component" suggests to
treat upper case letters as equivalent to lower case in scheme names (e.g., allow "HTTP" as well as "http")

Also, can you elaborate what motivates the selection of only "file://" and "http://"; as protocols? For instance, whereever HTTP is used the option of HTTPS isn't that far. FTP?

Would it maybe better match your intention to just always call URL.openStream() and fallback to the FileInputStream in the case the former method threw an exception ("unknown protocol")?

I will sure enhance it in the future, for now I only needed a specific protocol and ability to blend files and URLs. I don't want to enlarge the footprint, so ftp is not gonna make it :)

Thanks,
Oleg

Benjamin



[0] http://www.faqs.org/rfcs/rfc2396.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to