From feecc27677783328c7712d226985713af2e0d9f5 Mon Sep 17 00:00:00 2001 From: Douglas Cardoso Date: Fri, 22 Dec 2017 14:54:10 +0100 Subject: [PATCH] Log inaccessible file in RandomAccessDataFile Closes gh-11401 --- .../boot/loader/data/RandomAccessDataFile.java | 3 ++- .../boot/loader/data/RandomAccessDataFileTests.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java index 0ee62307c8..fc52bbdaaa 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java @@ -64,7 +64,8 @@ public class RandomAccessDataFile implements RandomAccessData { throw new IllegalArgumentException("File must not be null"); } if (!file.exists()) { - throw new IllegalArgumentException("File must exist"); + throw new IllegalArgumentException(String.format( + "File %s must exist", file.getAbsolutePath())); } this.file = file; this.filePool = new FilePool(file, concurrentReads); diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java index a38f272dab..e6c3aefc47 100644 --- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java +++ b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java @@ -106,7 +106,7 @@ public class RandomAccessDataFileTests { @Test public void fileExists() throws Exception { this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("File must exist"); + this.thrown.expectMessage("File /does/not/exist must exist"); new RandomAccessDataFile(new File("/does/not/exist")); } @@ -120,7 +120,7 @@ public class RandomAccessDataFileTests { @Test public void fileExistsWithConcurrentReads() throws Exception { this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("File must exist"); + this.thrown.expectMessage("File /does/not/exist must exist"); new RandomAccessDataFile(new File("/does/not/exist"), 1); }