Fix thread safety, resource leaks, and error handling across core and external modules #1928
Closed
dpol1 wants to merge 1 commit into
Closed
Fix thread safety, resource leaks, and error handling across core and external modules #1928dpol1 wants to merge 1 commit into
dpol1 wants to merge 1 commit into
Conversation
- Replace SimpleDateFormat with DateTimeFormatter/DateUtils (thread safety)
- Replace shared Matcher in RefreshTag with per-call instance (thread safety)
- Use try-with-resources for streams in FileResponse and RegexURLFilterBase
- Add cleanup() to DebugParseFilter to close output stream
- Stop Playwright tracing in finally block to prevent resource leak
- Handle NumberFormatException in FetcherBolt for metadata delay/thread values
- Add null check for missing classpath resource in RegexURLFilterBase
- Fix duplicate setExpiryDate() call in CookieConverter
- Fix error message typo in CloudSearchUtils ("must be" -> "must NOT be")
- Replace e.printStackTrace() with SLF4J LOG.error() throughout
- Use StandardCharsets overload of URLEncoder.encode() in S3 bolts
- Replace manual MessageDigest with DigestUtils.sha512Hex()
- Use detected charset in JsRenderingDetector instead of hardcoded UTF-8
Contributor
|
Thanks @dpol1. Having a PR affecting loads of different files and covering such different aspects does not make it easy to review. Instead of a large dump, having one PR per type of issue (e.g. Resource Leaks) means that changes can be reviewed quicker, merged in isolation and also reviewed in parallel. |
Member
Author
|
Sure, sorry about that — got a bit carried away. Will split it into three PRs: thread-safety, resource leaks, and fault tolerance/cleanup. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses a set of code quality, correctness, and robustness issues found across the
coreandexternalmodules.Thread Safety
SimpleDateFormatwithDateTimeFormatterinFileResponseandDateUtils.parseDate()inCookieConverterMatcherinRefreshTagwith aPatternconstant and per-callMatcherinstancesResource Leaks
FileInputStreaminFileResponseandInputStreaminRegexURLFilterBasecleanup()toDebugParseFilterto close the output streamfinallyblock inHttpProtocol, even when an exception is thrownError Handling & Robustness
Long.parseLong()/Integer.parseInt()inFetcherBoltwith try-catch to handle invalid metadata values gracefullyRegexURLFilterBasesetExpiryDate()call and add null guard inCookieConverterCloudSearchUtils("must be score" → "must NOT be score")Logging & Code Cleanup
e.printStackTrace()calls with proper SLF4JLOG.error()URLEncoder.encode(url, "UTF-8")(unnecessary checked exception) with theStandardCharsets.UTF_8overloadMessageDigestboilerplate withDigestUtils.sha512Hex()JsRenderingDetectorinstead of hardcoded UTF-8No behavior changes intended
All changes are backward-compatible. The crawl logic and output remain the same.