zkytech opened a new pull request, #5134:
URL: https://github.com/apache/zeppelin/pull/5134

   ### What is this PR for?
   
   This PR fixes a critical NullPointerException that occurs when users update 
interpreter settings from the frontend UI with "Set permission" enabled. When 
the interpreter configuration is updated, the new `InterpreterOption` object is 
deserialized from JSON without the `zConf` field being initialized (as it's 
marked `transient`). This causes NPE during paragraph execution when checking 
user authorization.
   
   The fix ensures that `zConf` is properly propagated to the new 
`InterpreterOption` when settings are updated, and adds defensive null checks 
to prevent NPE in edge cases.
   
   ### What type of PR is it?
   
   Bug Fix
   
   ### Todos
   
   * [x] - Identify root cause of NPE in InterpreterOption.getOwners()
   * [x] - Implement fix in InterpreterSetting.setOption() to propagate zConf
   * [x] - Add defensive null check in InterpreterOption.getOwners()
   * [x] - Manual testing with permission-enabled interpreters
   
   ### What is the Jira issue?
   
   * [ZEPPELIN-6378] - NullPointerException occurred when set permission to 
interpreter
   
   ### How should this be tested?
   
   #### Manual Testing Steps:
   
   1. **Setup**
      - Start Zeppelin server
      - Navigate to Interpreter settings page
   
   2. **Reproduce the bug (before fix)**
      - Select any interpreter (e.g., Spark, Python, JDBC)
      - **Enable "Set permission" option** (critical - bug only occurs when 
this is enabled)
      - Add one or more owners to the interpreter
      - Modify any interpreter property
      - Click "Save"
      - Create/open a notebook and execute a code paragraph
      - **Expected (before fix)**: NullPointerException is thrown
      - **Expected (after fix)**: Code executes successfully
   
   3. **Verify the fix**
      - Repeat steps above with the fix applied
      - Code should execute without errors
      - Test with different scenarios:
        - Multiple owners configured
        - Different interpreter types
        - Username force lowercase enabled/disabled in `zeppelin-site.xml`
        - Permission enabled/disabled
   
   #### Automated Testing:
   
   Existing test suite should pass:
   - `InterpreterSettingTest` - Tests interpreter setting operations
   - `InterpreterSettingManagerTest` - Tests interpreter setting management
   
   #### Stack Trace (Before Fix):
   
   <img width="919" height="536" alt="image" 
src="https://github.com/user-attachments/assets/51bbf9ab-ef0c-4b1c-b569-a1d7dc9b2e7d";
 />
   
   ```
   java.lang.NullPointerException
        at 
org.apache.zeppelin.interpreter.InterpreterOption.getOwners(InterpreterOption.java:76)
        at 
org.apache.zeppelin.interpreter.InterpreterSetting.isUserAuthorized(InterpreterSetting.java:822)
        at org.apache.zeppelin.notebook.Paragraph.jobRun(Paragraph.java:415)
        at org.apache.zeppelin.notebook.Paragraph.jobRun(Paragraph.java:68)
        at org.apache.zeppelin.scheduler.Job.run(Job.java:187)
        at 
org.apache.zeppelin.scheduler.AbstractScheduler.runJob(AbstractScheduler.java:136)
        at 
org.apache.zeppelin.scheduler.RemoteScheduler$JobRunner.run(RemoteScheduler.java:186)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
   ```
   
   #### Root Cause Analysis:
   ```
   Frontend Update → InterpreterRestApi.updateSetting()
                   → InterpreterSettingManager.setPropertyAndRestart()
                   → InterpreterSettingManager.inlineSetPropertyAndRestart()
                   → InterpreterSetting.setOption(newOption)  ← zConf not set 
on new option
                   
   User Executes Code → Paragraph.jobRun()
                      → InterpreterSetting.isUserAuthorized()
                      → InterpreterOption.getOwners()
                      → zConf.isUsernameForceLowerCase()  ← NPE occurs here
   ```
   
   ### Screenshots (if appropriate)
   
   N/A - Backend bug fix with no UI changes
   
   ### Questions:
   
   * **Does the license files need to update?**
     - No - No new dependencies or third-party code added
   
   * **Is there breaking changes for older versions?**
     - No - This is a backward-compatible bug fix that adds defensive null 
checks and ensures proper initialization
   
   * **Does this needs documentation?**
     - No - Internal bug fix that doesn't change user-facing behavior or APIs
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to