Skip to content

Conversation

@richardelms
Copy link
Contributor

@richardelms richardelms commented Dec 17, 2025

This pull request enhances the Bugsnag Java notifier to allow ignoring exception classes using Java regex patterns, enabling more flexible and powerful filtering of exceptions. The change replaces the previous exact string matching with regex-based matching for discarded exception classes, updates the configuration and API accordingly, and adds comprehensive tests and scenarios for wildcard and multiple pattern support.

Regex-based exception class filtering:

  • The setDiscardClasses API in Bugsnag and Configuration now accepts compiled Pattern objects instead of strings, allowing users to specify regex patterns for exception class names to ignore. This enables wildcard and pattern-based filtering instead of only exact matches. [1] [2]
  • The shouldIgnoreClass logic in Configuration is updated to match exception class names using the provided regex patterns.
  • The BugsnagAppender is updated to compile string patterns to Pattern objects before passing them to Bugsnag, ensuring compatibility with the new API. [1] [2]

Testing and validation:

  • A new test class, ConfigurationDiscardClassesTest, is added to cover various regex matching scenarios, including wildcards, multiple patterns, special characters, and empty/null patterns.
  • Existing tests in BugsnagTest and AppenderTest are updated to use and validate the new regex-based API. [1] [2]

Feature scenarios and configuration:

  • New feature files and scenarios are added to verify wildcard and multiple-pattern behavior in both plain Java and Spring applications, as well as for the Logback appender. [1] [2]
  • Example scenarios (IgnoredExceptionWildcardScenario, MultipleWildcardPatternsScenario) and logback configuration are provided to demonstrate and test the new regex-based discard functionality. [1] [2] [3]

Supporting code changes:

  • Internal data structures in Configuration are updated to store and serialize both the compiled Pattern objects and their string representations for backward compatibility and configuration introspection. [1] [2]

These changes significantly improve the flexibility of exception filtering in Bugsnag Java integrations, making it easier to ignore groups of exceptions using patterns.

References: [1] [2] [3] [4] [5]

@richardelms richardelms self-assigned this Dec 17, 2025
@richardelms richardelms requested a review from Copilot December 17, 2025 13:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements pattern matching support for the discardClasses configuration in Bugsnag, allowing users to filter exception classes using glob-style wildcards (* and ?) in addition to exact matches.

Key changes:

  • Enhanced Configuration.shouldIgnoreClass() to support wildcard pattern matching using compiled regex patterns
  • Maintained backward compatibility with exact class name matching
  • Added comprehensive test coverage for pattern matching scenarios

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
bugsnag/src/main/java/com/bugsnag/Configuration.java Core implementation of pattern matching logic with regex conversion and pattern storage
bugsnag/src/test/java/com/bugsnag/ConfigurationDiscardClassesTest.java Unit tests covering exact matches, wildcards, multiple patterns, and edge cases
features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/MultipleWildcardPatternsScenario.java Integration test scenario for multiple wildcard patterns
features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/IgnoredExceptionWildcardScenario.java Integration test scenario for wildcard-based exception filtering
features/multiple_wildcard_patterns.feature Feature test for multiple wildcard patterns functionality
features/ignored_reports_wildcard.feature Feature tests for wildcard pattern filtering across different app types
features/fixtures/logback/ignored_class_wildcard_config.xml Logback configuration example demonstrating wildcard usage
DISCARD_CLASSES_PATTERN_MATCHING.md Documentation for the new pattern matching feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@richardelms richardelms requested a review from Copilot December 18, 2025 11:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@richardelms richardelms marked this pull request as ready for review December 18, 2025 14:52
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

Successfully merging this pull request may close these issues.

2 participants