Skip to content

Commit 5db3f8a

Browse files
committed
Use custom field for filename instead of exception message in ProducerFileNotFoundException
1 parent daf7312 commit 5db3f8a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/main/java/org/vafer/jdeb/DataBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ private void createParentDirectories( String filename, String user, long uid, St
282282
data.produce(receiver);
283283
}
284284
} catch (ProducerFileNotFoundException e) {
285-
// Get the offending file name from the exception message to check
285+
// Get the offending file name from the exception to check
286286
// if it's a symlink.
287-
if (Files.isSymbolicLink(Paths.get(e.getMessage())) && ignoreBrokenLinks) {
287+
if (Files.isSymbolicLink(Paths.get(e.getFilePath())) && ignoreBrokenLinks) {
288288
console.info("Ignoring broken symlink " + e.getMessage());
289289
}
290290
else {

src/main/java/org/vafer/jdeb/ProducerFileNotFoundException.java

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
public class ProducerFileNotFoundException extends FileNotFoundException {
66

7+
private String filePath;
78

89
public ProducerFileNotFoundException() {
910
super();
@@ -17,4 +18,12 @@ public ProducerFileNotFoundException(String message, Throwable cause) {
1718
super(message);
1819
this.initCause(cause);
1920
}
21+
22+
public void setFilePath(String path) {
23+
this.filePath = path;
24+
}
25+
26+
public String getFilePath() {
27+
return this.filePath;
28+
}
2029
}

src/main/java/org/vafer/jdeb/producers/AbstractDataProducer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public void produceFile( final DataConsumer consumer,
9191
Producers.produceInputStreamWithEntry(consumer, new FileInputStream(file), fileEntry);
9292
}
9393
catch (FileNotFoundException e) {
94-
ProducerFileNotFoundException pe = new ProducerFileNotFoundException(file.getAbsolutePath(), e);
94+
ProducerFileNotFoundException pe = new ProducerFileNotFoundException(e.getMessage(), e);
95+
pe.setFilePath(file.getAbsolutePath());
9596
throw pe;
9697
}
9798
}

0 commit comments

Comments
 (0)