Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable hash due to unstable class names. #3

Open
DaanVanYperen opened this issue Apr 20, 2018 · 0 comments
Open

Unstable hash due to unstable class names. #3

DaanVanYperen opened this issue Apr 20, 2018 · 0 comments

Comments

@DaanVanYperen
Copy link

Javassist class naming isn't stable between builds which causes the exception hash to shift.

com.example.Service_$$_javassist_seam_92/throwException
com.example.Service_$$_javassist_seam_43/throwException

Since others might be stuck with the same legacy frameworks decided to submit this workaround. It kills $$ suffixes. No guarantees how nice it plays with other bytecode manipulation libs.

Thanks for making exhash. :)

    private class StacktraceJavassistWorkaround implements IStacktrace {
        private final String cleanTrace;
        private static final String REGEXP_MATCH_JAVASSIST_SUFFIX = "_\\$\\$_\\S+(?=\\/)"; // cut off dynamic _$$_ bit

        public StacktraceJavassistWorkaround(IStacktrace stacktrace) {
            cleanTrace = filterJavassistSuffix(stacktrace.getStacktraceText());
        }

        private String filterJavassistSuffix(String stacktraceText) {
            final StringBuilder builder = new StringBuilder();
            new BufferedReader(new StringReader(stacktraceText))
                    .lines().forEach(s -> {
                builder.append(s.replaceAll(REGEXP_MATCH_JAVASSIST_SUFFIX, "")).append("\n");
            });
            return builder.toString();
        }

        @Override
        public String getStacktraceText() {
            return cleanTrace;
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant