Fixrleak:使用GenAI修复Java资源泄漏

Resource leaks, where resources like files, database connections, or streams aren’t properly released after use, are a persistent issue in Java applications. These leaks can lead to performance degradation,  and system failures. While tools like SonarSource SonarQube™ effectively identify such leaks, the fixing process remains manual, time-consuming, and prone to errors. To address this, we developed FixrLeak, a generative AI-based framework that automates the detection and repair of resource leaks. FixrLeak combines Abstract Syntax Tree (AST) analysis with generative AI (GenAI) to produce accurate, idiomatic fixes while following Java best practices like try-with-resources. Deployed within Uber’s extensive Java codebase, FixrLeak significantly reduces manual effort, improves developer productivity, and improves code quality, showcasing the transformative potential of AI-driven solutions in large-scale software engineering.

资源泄漏,即文件、数据库连接或流等资源在使用后未被正确释放,是Java应用程序中的一个持续问题。这些泄漏可能导致性能下降和系统故障。虽然像SonarSource SonarQube™这样的工具有效识别此类泄漏,但修复过程仍然是手动的、耗时的,并且容易出错。为了解决这个问题,我们开发了FixrLeak,一个基于生成AI的框架,自动检测和修复资源泄漏。FixrLeak结合了抽象语法树(AST)分析和生成AI(GenAI),在遵循Java最佳实践(如try-with-resources)的同时,生成准确、符合习惯的修复。FixrLeak在Uber广泛的Java代码库中部署,显著减少了手动工作,提高了开发人员的生产力,并改善了代码质量,展示了AI驱动解决方案在大规模软件工程中的变革潜力。

Resource leaks occur when a program fails to properly release resources such as files, database connections, or streams after use. These leaks can lead to serious issues, including performance degradation, application failures, and an inability to handle additional operations due to resource exhaustion. For example, if a file descriptor isn’t released quickly, it could prevent an application from opening new files, ultimately causing system instability.

资源泄漏发生在程序未能在使用后正确释放资源,如文件、数据库连接或流。这些泄漏可能导致严重问题,包括性能下降、应用程序故障,以及由于资源耗尽而无法处理额外操作。例如,如果文件描述符未能迅速释放,可能会阻止应用程序打开新文件,最终导致系统不稳定。

Consider the example below, where a BufferedReader object is used to read from a file. In the original code (Figure 1), the reader isn’t closed properly, resulting in a resource leak. ...

开通本站会员,查看完整译文。

Home - Wiki
Copyright © 2011-2025 iteam. Current version is 2.143.0. UTC+08:00, 2025-05-03 08:55
浙ICP备14020137号-1 $Map of visitor$