Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceCollection should not have a path #8711

Merged
merged 21 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7f2351b
ResourceCollection should not have a path
gregw Oct 13, 2022
4164248
ResourceCollection should not have a path
gregw Oct 13, 2022
18fed53
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Oct 18, 2022
d939545
ResourceCollection should not have a path
gregw Oct 18, 2022
8e3e526
ResourceCollection should not have a path
gregw Oct 18, 2022
5d9db3c
ResourceCollection should not have a path
gregw Oct 18, 2022
3b5f0ea
ResourceCollection should not have a path
gregw Oct 18, 2022
b25c15d
ResourceCollection should not have a path
gregw Oct 18, 2022
e80f985
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Oct 18, 2022
4288982
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Oct 20, 2022
f74c496
ResourceCollection should not have a path
gregw Oct 20, 2022
e4e7caf
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Oct 24, 2022
2a0c92a
renamed to CombinedResource
gregw Oct 24, 2022
9ec4666
Merge branch 'jetty-12.0.x' into jetty-12.0.x-resourceCollect-no-path
gregw Oct 26, 2022
d3b61ef
replaced getPathInContext with static method
gregw Oct 26, 2022
55b554d
replaced getPathInContext with static method
gregw Oct 27, 2022
da712b1
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Oct 29, 2022
1b95cac
Removed stream from Resource
gregw Oct 31, 2022
1c1dd71
Removed stream from Resource
gregw Oct 31, 2022
a5d947c
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Oct 31, 2022
3eabb54
fixed javadoc
gregw Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ public long length()
*/
public InputStream newInputStream() throws IOException
{
return Files.newInputStream(getPath(), StandardOpenOption.READ);
Path path = getPath();
if (path == null)
return null;
gregw marked this conversation as resolved.
Show resolved Hide resolved
return Files.newInputStream(path, StandardOpenOption.READ);
}

/**
Expand All @@ -241,6 +244,9 @@ public InputStream newInputStream() throws IOException
*/
public ReadableByteChannel newReadableByteChannel() throws IOException
gregw marked this conversation as resolved.
Show resolved Hide resolved
{
Path path = getPath();
if (path == null)
return null;
return Files.newByteChannel(getPath(), StandardOpenOption.READ);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@

package org.eclipse.jetty.util.resource;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList;
Expand Down Expand Up @@ -166,88 +163,36 @@ public boolean exists()
@Override
public Path getPath()
{
for (Resource r : _resources)
{
Path p = r.getPath();
if (p != null)
return p;
}
return null;
}

@Override
public InputStream newInputStream() throws IOException
{
for (Resource r : _resources)
{
if (!r.exists())
{
// Skip, cannot open anyway
continue;
}
InputStream is = r.newInputStream();
if (is != null)
{
return is;
}
}

throw new FileNotFoundException("Resource does not exist");
}

@Override
public ReadableByteChannel newReadableByteChannel() throws IOException
{
for (Resource r : _resources)
{
ReadableByteChannel channel = r.newReadableByteChannel();
if (channel != null)
{
return channel;
}
}
return null;
}

@Override
public String getName()
{
for (Resource r : _resources)
{
String name = r.getName();
if (name != null)
{
return name;
}
}
return null;
}

@Override
public String getFileName()
{
String filename = null;
// return a non-null filename only if all resources agree on the same name.
for (Resource r : _resources)
{
String filename = r.getFileName();
if (filename != null)
{
return filename;
}
String fn = r.getFileName();
if (fn == null)
return null;
if (filename == null)
filename = fn;
else if (!filename.equals(fn))
return null;
}
return null;
return filename;
}

@Override
public URI getURI()
{
for (Resource r : _resources)
{
URI uri = r.getURI();
if (uri != null)
{
return uri;
}
}
return null;
}

Expand Down