From 8e6f5c4961960afdbeb4d0932967841e07ff779d Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 18 Oct 2024 15:23:57 -0500 Subject: [PATCH] Throw EmbeddedRedisException if server fails to start --- .../java/redis/embedded/AbstractRedisInstance.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/redis/embedded/AbstractRedisInstance.java b/src/main/java/redis/embedded/AbstractRedisInstance.java index adc145dc..da23f946 100644 --- a/src/main/java/redis/embedded/AbstractRedisInstance.java +++ b/src/main/java/redis/embedded/AbstractRedisInstance.java @@ -63,16 +63,16 @@ private void logErrors() { private void awaitRedisServerReady() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(redisProcess.getInputStream())); try { - StringBuffer outputStringBuffer = new StringBuffer(); + StringBuilder outputStringBuilder = new StringBuilder(); String outputLine; do { outputLine = reader.readLine(); if (outputLine == null) { - //Something goes wrong. Stream is ended before server was activated. - throw new RuntimeException("Can't start redis server. Check logs for details. Redis process log: " + outputStringBuffer.toString()); + // Something is wrong. Stream ended before server was activated. + throw new EmbeddedRedisException("Redis server failed to become ready. Check logs for details. Redis process log: " + outputStringBuilder.toString()); } else { - outputStringBuffer.append("\n"); - outputStringBuffer.append(outputLine); + outputStringBuilder.append("\n"); + outputStringBuilder.append(outputLine); } } while (!outputLine.matches(redisReadyPattern())); } finally {