Skip to content
Merged
Changes from all commits
Commits
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 @@ -18,8 +18,7 @@ public static LineString coorConvertPath(List<CoordinateDto> path) {
try {
return getLineString(path);
} catch (Exception e) {
log.warn("course 요청 데이터 값 (path) -> " + path);
log.warn("course 요청 데이터 값의 타입 (path) -> " + path.getClass().getName());
log.warn("course 요청 데이터 변환 실패 (size={}, type={}): {}", path.size(), path.getClass().getName(), e.getMessage());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Keep failure logging null-safe.

When path is null, getLineString(path) fails first, but the catch block then evaluates path.size() and path.getClass(). The handler throws NullPointerException instead of the intended BadRequestException.

Use null-safe size/type values or validate path before conversion.

Proposed fix
-            log.warn("course 요청 데이터 변환 실패 (size={}, type={}): {}", path.size(), path.getClass().getName(), e.getMessage());
+            log.warn("course 요청 데이터 변환 실패 (size={}, type={}): {}",
+                path == null ? null : path.size(),
+                path == null ? "null" : path.getClass().getName(),
+                e.getMessage());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
log.warn("course 요청 데이터 변환 실패 (size={}, type={}): {}", path.size(), path.getClass().getName(), e.getMessage());
log.warn("course 요청 데이터 변환 실패 (size={}, type={}): {}",
path == null ? null : path.size(),
path == null ? "null" : path.getClass().getName(),
e.getMessage());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/runnect/server/common/module/convert/CoordinatePathConverter.java`
at line 21, Update the failure logging in CoordinatePathConverter so the catch
handler remains null-safe when path is null. Replace direct path.size() and
path.getClass() access with null-safe size and type values, or validate path
before getLineString(path), while preserving the intended BadRequestException
flow.

throw new BadRequestException(ErrorStatus.VALIDATION_COURSE_PATH_EXCEPTION, ErrorStatus.VALIDATION_COURSE_PATH_EXCEPTION.getMessage());
}
}
Expand All @@ -43,16 +42,11 @@ public static List<List<Double>> pathConvertCoor(LineString path) {
}

private static LineString getLineString(List<CoordinateDto> coordinateDtos) {
StringBuilder sb = new StringBuilder();
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
Coordinate[] coordinates = new Coordinate[coordinateDtos.size()];
for (int i = 0; i < coordinateDtos.size(); i++) {
coordinates[i] = new Coordinate(coordinateDtos.get(i).getLatitude(), coordinateDtos.get(i).getLongitude());
sb.append("(" + coordinateDtos.get(i).getLatitude() + ", " + coordinateDtos.get(i).getLongitude() + ")");
}
LineString lineString = geometryFactory.createLineString(coordinates);
log.info("create course!");
log.info(sb.toString());
return lineString;
return geometryFactory.createLineString(coordinates);
}
}
Loading