Skip to content

Commit

Permalink
Showing 2 changed files with 25 additions and 4 deletions.
23 changes: 19 additions & 4 deletions core/src/main/java/org/jruby/util/URLResource.java
Original file line number Diff line number Diff line change
@@ -94,10 +94,25 @@ public long lastModified()
}

@Override
public long length()
{
// TODO Auto-generated method stub
return 0;
public long length() {
long totalRead = 0;
InputStream is = null;

try {
is = openInputStream();
byte[] buf = new byte[8096];
int amountRead;

while ((amountRead = is.read(buf)) != -1) {
totalRead += amountRead;
}

is.close();
} catch (IOException e) {
if (is != null) try { is.close(); } catch (IOException e2) {}
}

return totalRead;
}

@Override
6 changes: 6 additions & 0 deletions spec/java_integration/utilities/load_from_jar_spec.rb
Original file line number Diff line number Diff line change
@@ -13,6 +13,12 @@
expect($LOADED_FEATURES.pop).to eq("#{jar}!/abc/foo.rb")
end

it "blegh" do
jar = File.expand_path("test/jruby/dir with spaces/test_jar.jar")
load jar
expect(File.size?("uri:classloader:/inside_jar.rb")).to eq(108)
end

# JRUBY-4774, WARBLER-15
it "works with classpath URLs that have spaces in them" do
url_loader = java.net.URLClassLoader.new([java.net.URL.new("file:" + File.expand_path("test/jruby/dir with spaces/test_jar.jar"))].to_java(java.net.URL))

0 comments on commit 6461ece

Please sign in to comment.