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

bugfix: native-image AOT runtime GBK encoding error #368

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

funky-eyes
Copy link
Contributor

@funky-eyes funky-eyes commented Jan 24, 2025

Sofa-Middleware-Log:ERROR [com.alipay.remoting] Build ILoggerFactory error! Default app logger will be used.
java.lang.IllegalStateException: Logback loggerSpaceFactory build error
        at com.alipay.sofa.common.log.factory.LogbackLoggerSpaceFactory.<init>(LogbackLoggerSpaceFactory.java:73)
        at com.alipay.sofa.common.log.factory.LoggerSpaceFactory4LogbackBuilder.doBuild(LoggerSpaceFactory4LogbackBuilder.java:44)
        at com.alipay.sofa.common.log.factory.AbstractLoggerSpaceFactoryBuilder.build(AbstractLoggerSpaceFactoryBuilder.java:67)
        at com.alipay.sofa.common.log.MultiAppLoggerSpaceManager.createILoggerFactory(MultiAppLoggerSpaceManager.java:305)
        at com.alipay.sofa.common.log.MultiAppLoggerSpaceManager.getILoggerFactoryBySpaceName(MultiAppLoggerSpaceManager.java:194)
        at com.alipay.sofa.common.log.MultiAppLoggerSpaceManager.getLoggerBySpace(MultiAppLoggerSpaceManager.java:173)
        at com.alipay.sofa.common.log.LoggerSpaceManager.getLoggerBySpace(LoggerSpaceManager.java:101)
        at com.alipay.sofa.common.log.LoggerSpaceManager.getLoggerBySpace(LoggerSpaceManager.java:75)
        at com.alipay.sofa.common.log.LoggerSpaceManager.getLoggerBySpace(LoggerSpaceManager.java:46)
        at com.alipay.remoting.log.BoltLoggerFactory.getLogger(BoltLoggerFactory.java:86)
        at com.alipay.remoting.AbstractRemotingServer.<clinit>(AbstractRemotingServer.java:42)
        at [email protected]/java.lang.Class.ensureInitialized(DynamicHub.java:650)
        at icu.funkye.redispike.common.BoltServer.<init>(BoltServer.java:34)
        at icu.funkye.redispike.Server.start(Server.java:89)
        at icu.funkye.redispike.ProxyMain.main(ProxyMain.java:25)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: ch.qos.logback.core.joran.spi.JoranException: I/O error occurred while parsing xml file
        at ch.qos.logback.core.joran.event.SaxEventRecorder.handleError(SaxEventRecorder.java:74)
        at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:62)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:151)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
        at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:64)
        at com.alipay.sofa.common.log.factory.LogbackLoggerSpaceFactory.<init>(LogbackLoggerSpaceFactory.java:71)
        ... 15 more
Caused by: java.io.UnsupportedEncodingException: GBK
        at [email protected]/sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:79)
        at [email protected]/java.io.InputStreamReader.<init>(InputStreamReader.java:113)
        at [email protected]/com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.createReader(XMLEntityScanner.java:1858)
        at [email protected]/com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.setEncoding(XMLEntityScanner.java:479)
        at [email protected]/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl(XMLDocumentFragmentScannerImpl.java:1033)
        at [email protected]/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$XMLDeclDriver.next(XMLDocumentScannerImpl.java:782)
        at [email protected]/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:635)
        at [email protected]/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:113)
        at [email protected]/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:482)
        at [email protected]/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:890)
        at [email protected]/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:826)
        at [email protected]/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:134)
        at [email protected]/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1225)
        at [email protected]/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
        at [email protected]/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:326)
        at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:59)
        ... 20 more

Summary by CodeRabbit

  • Version Update

    • Updated project version from 1.6.11 to 1.6.12-SNAPSHOT
  • Configuration

    • Updated Logback logging configuration to use UTF-8 encoding
    • Updated Log4j logging configuration to use UTF-8 encoding
    • Updated Log4j 2.x logging configuration to use UTF-8 encoding

Copy link

coderabbitai bot commented Jan 24, 2025

"""

Walkthrough

The pull request involves updates to the pom.xml file, changing the project version from 1.6.11 to 1.6.12-SNAPSHOT, indicating a transition to a snapshot version. Additionally, the character encoding in multiple logging configuration files (Logback and Log4j) has been modified from GBK to UTF-8, which affects how text is interpreted in these files.

Changes

File Change Summary
pom.xml Version updated from 1.6.11 to 1.6.12-SNAPSHOT
src/main/resources/com/alipay/remoting/log/logback/log-conf.xml Encoding changed from GBK to UTF-8
src/main/resources/com/alipay/remoting/log/log4j/log-conf.xml Encoding changed from GBK to UTF-8
src/main/resources/com/alipay/remoting/log/log4j2/log-conf.xml Encoding changed from GBK to UTF-8

Poem

🐰 A rabbit's versioning dance,
Snapshot's whisper, a code's new chance.
UTF-8 encoding bright,
Replacing GBK's old might,
Hop forward with each small change! 🚀
"""

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4379468 and 9e9dbd2.

📒 Files selected for processing (2)
  • src/main/resources/com/alipay/remoting/log/log4j/log-conf.xml (1 hunks)
  • src/main/resources/com/alipay/remoting/log/log4j2/log-conf.xml (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/main/resources/com/alipay/remoting/log/log4j/log-conf.xml
  • src/main/resources/com/alipay/remoting/log/log4j2/log-conf.xml
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (21)
  • GitHub Check: build (17)
  • GitHub Check: build (11)
  • GitHub Check: build (8)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@funky-eyes
Copy link
Contributor Author

After changing to UTF-8, everything works fine when running the AOT package under GraalVM version 23, and the exception is no longer output

@funky-eyes funky-eyes closed this Jan 24, 2025
@funky-eyes funky-eyes reopened this Jan 24, 2025
@funky-eyes funky-eyes closed this Jan 24, 2025
@funky-eyes funky-eyes reopened this Jan 24, 2025
@funky-eyes
Copy link
Contributor Author

@chuailiwu @OrezzerO PTAL

@OrezzerO
Copy link
Collaborator

OrezzerO commented Feb 5, 2025

There are other files using wrong configuration:

  1. src/main/resources/com/alipay/remoting/log/log4j2/log-conf.xml
  2. src/main/resources/com/alipay/remoting/log/logback/log-conf.xml

Please correct these files as well.

@funky-eyes funky-eyes closed this Feb 5, 2025
@funky-eyes funky-eyes reopened this Feb 5, 2025
@funky-eyes funky-eyes closed this Feb 5, 2025
@funky-eyes funky-eyes reopened this Feb 5, 2025
Copy link
Collaborator

@OrezzerO OrezzerO left a comment

Choose a reason for hiding this comment

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

LGTM

@EvenLjj EvenLjj merged commit db68f89 into sofastack:master Feb 5, 2025
8 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants