This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 876d1dc7fd [ZEPPELIN-6071] Bump pty4j version to 0.12.10-jdk8
876d1dc7fd is described below

commit 876d1dc7fd460fffbe855873bc5a65865bcd0f78
Author: ChanHo Lee <chanho0...@gmail.com>
AuthorDate: Thu Sep 19 15:05:27 2024 +0900

    [ZEPPELIN-6071] Bump pty4j version to 0.12.10-jdk8
    
    This PR is reopening #4806
    
    ### What is this PR for?
    Previous pty4j dependency version does not support Silicon OSX
    So `%sh.terminal` interpreter did not work on Silicon OSX.
    To fix this, I bumped pty4j version to 0.12.35
    
    The previous `pty4j` dependency version does not support macOS on Apple 
Silicon.
    As a result, the `%sh.terminal` interpreter did not work on Apple Silicon 
macOS.
    To fix this issue, I have updated the `pty4j` verison to `0.12.35`
    
    ### What type of PR is it?
    Bug Fix
    
    ### What is the Jira issue?
    * Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/6071
    
    ### How should this be tested?
    
    - Run `%sh.terminal` interpreter
      - Main focus : Test on a Mac with Apple Silicon to ensure it works 
correctly.
      - The native files for other OS/architectures have also changed to match 
the library version downgrade. It would be helpful to verify that it functions 
properly on these other OS/architectures as well.
    
    ### Screenshots (if appropriate)
    
    #### Before
    
    <img width="1498" alt="image" 
src="https://github.com/user-attachments/assets/2ee6c9f9-7a1c-41d0-831a-900949d2c9bc";>
    
    - The interpreter was not working, and these error logs were generated:
    ```
    ERROR [2024-09-01 14:10:18,305] ({Thread-11} PtyHelpers.java[<clinit>]:231) 
- Cannot load implementation of interface com.pty4j.unix.PtyHelpers$OSFacade
    java.lang.UnsatisfiedLinkError: Can't load library: 
/var/folders/bt/g5zw1jfn36783j9xvwl6pmg80000gn/T/jna-738948474/jna9752198374376500371.tmp
            at 
java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2638)
            at java.base/java.lang.Runtime.load0(Runtime.java:768)
            at java.base/java.lang.System.load(System.java:1854)
            at 
com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:947)
            at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:922)
            at com.sun.jna.Native.<clinit>(Native.java:190)
            at com.pty4j.unix.macosx.OSFacadeImpl.<clinit>(OSFacadeImpl.java:91)
            at com.pty4j.unix.PtyHelpers$1.call(PtyHelpers.java:200)
            at com.pty4j.unix.PtyHelpers$1.call(PtyHelpers.java:196)
            at com.pty4j.util.LazyValue.getValue(LazyValue.java:25)
            at com.pty4j.unix.PtyHelpers.getOsFacade(PtyHelpers.java:244)
            at com.pty4j.unix.PtyHelpers.<clinit>(PtyHelpers.java:228)
            at com.pty4j.unix.Pty.ptyMasterOpen(Pty.java:141)
            at com.pty4j.unix.Pty.openMaster(Pty.java:193)
            at com.pty4j.unix.Pty.<init>(Pty.java:56)
            at com.pty4j.unix.UnixPtyProcess.<init>(UnixPtyProcess.java:83)
            at com.pty4j.PtyProcessBuilder.start(PtyProcessBuilder.java:111)
            at com.pty4j.PtyProcess.exec(PtyProcess.java:78)
            at com.pty4j.PtyProcess.exec(PtyProcess.java:49)
            at 
org.apache.zeppelin.shell.terminal.service.TerminalService.initializeProcess(TerminalService.java:88)
            at 
org.apache.zeppelin.shell.terminal.service.TerminalService.lambda$onTerminalReady$0(TerminalService.java:62)
            at java.base/java.lang.Thread.run(Thread.java:829)
     INFO [2024-09-01 14:10:18,324] ({Thread-11} 
ExtractedNative.java[doInit]:127) - Extracted pty4j native in 17 ms
    ERROR [2024-09-01 14:10:18,325] ({Thread-11} PtyHelpers.java[<clinit>]:237) 
- Cannot load native pty executor library
    java.lang.NoClassDefFoundError: Could not initialize class 
com.sun.jna.Native
            at 
com.pty4j.unix.NativePtyExecutor.<init>(NativePtyExecutor.java:14)
            at com.pty4j.unix.PtyHelpers$2.call(PtyHelpers.java:222)
            at com.pty4j.unix.PtyHelpers$2.call(PtyHelpers.java:218)
            at com.pty4j.util.LazyValue.getValue(LazyValue.java:25)
            at com.pty4j.unix.PtyHelpers.getPtyExecutor(PtyHelpers.java:254)
            at com.pty4j.unix.PtyHelpers.<clinit>(PtyHelpers.java:234)
            at com.pty4j.unix.Pty.ptyMasterOpen(Pty.java:141)
            at com.pty4j.unix.Pty.openMaster(Pty.java:193)
            at com.pty4j.unix.Pty.<init>(Pty.java:56)
            at com.pty4j.unix.UnixPtyProcess.<init>(UnixPtyProcess.java:83)
            at com.pty4j.PtyProcessBuilder.start(PtyProcessBuilder.java:111)
            at com.pty4j.PtyProcess.exec(PtyProcess.java:78)
            at com.pty4j.PtyProcess.exec(PtyProcess.java:49)
            at 
org.apache.zeppelin.shell.terminal.service.TerminalService.initializeProcess(TerminalService.java:88)
            at 
org.apache.zeppelin.shell.terminal.service.TerminalService.lambda$onTerminalReady$0(TerminalService.java:62)
            at java.base/java.lang.Thread.run(Thread.java:829)
    ERROR [2024-09-01 14:10:18,325] ({Thread-11} 
TerminalService.java[lambda$onTerminalReady$0]:64) - Cannot load implementation 
of interface com.pty4j.unix.PtyHelpers$OSFacade
    java.lang.RuntimeException: Cannot load implementation of interface 
com.pty4j.unix.PtyHelpers$OSFacade
            at com.pty4j.unix.PtyHelpers.getOsFacade(PtyHelpers.java:247)
            at com.pty4j.unix.PtyHelpers.getInstance(PtyHelpers.java:262)
            at com.pty4j.unix.Pty.ptyMasterOpen(Pty.java:141)
            at com.pty4j.unix.Pty.openMaster(Pty.java:193)
            at com.pty4j.unix.Pty.<init>(Pty.java:56)
            at com.pty4j.unix.UnixPtyProcess.<init>(UnixPtyProcess.java:83)
            at com.pty4j.PtyProcessBuilder.start(PtyProcessBuilder.java:111)
            at com.pty4j.PtyProcess.exec(PtyProcess.java:78)
            at com.pty4j.PtyProcess.exec(PtyProcess.java:49)
            at 
org.apache.zeppelin.shell.terminal.service.TerminalService.initializeProcess(TerminalService.java:88)
            at 
org.apache.zeppelin.shell.terminal.service.TerminalService.lambda$onTerminalReady$0(TerminalService.java:62)
            at java.base/java.lang.Thread.run(Thread.java:829)
    Caused by: java.lang.UnsatisfiedLinkError: Can't load library: 
/var/folders/bt/g5zw1jfn36783j9xvwl6pmg80000gn/T/jna-738948474/jna9752198374376500371.tmp
            at 
java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2638)
            at java.base/java.lang.Runtime.load0(Runtime.java:768)
            at java.base/java.lang.System.load(System.java:1854)
            at 
com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:947)
            at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:922)
            at com.sun.jna.Native.<clinit>(Native.java:190)
            at com.pty4j.unix.macosx.OSFacadeImpl.<clinit>(OSFacadeImpl.java:91)
            at com.pty4j.unix.PtyHelpers$1.call(PtyHelpers.java:200)
            at com.pty4j.unix.PtyHelpers$1.call(PtyHelpers.java:196)
            at com.pty4j.util.LazyValue.getValue(LazyValue.java:25)
            at com.pty4j.unix.PtyHelpers.getOsFacade(PtyHelpers.java:244)
            at com.pty4j.unix.PtyHelpers.<clinit>(PtyHelpers.java:228)
            ... 10 more
    ```
    
    #### After
    
    <img width="1500" alt="image" 
src="https://github.com/user-attachments/assets/8a548b2c-e75b-4c6f-8607-7bbc4ac08159";>
    
    - The interpreter is now working as expected, just like any ordinary shell.
    
    ### Questions:
    * Does the license files need to update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    
    Closes #4822 from tbonelee/update-pty4j.
    
    Signed-off-by: Cheng Pan <cheng...@apache.org>
---
 shell/HTERM.md                                     | 197 ---------------------
 shell/PTY4J.md                                     | 135 --------------
 shell/pom.xml                                      |   2 +-
 .../zeppelin/shell/terminal/helper/IOHelper.java   | 180 -------------------
 .../shell/terminal/service/TerminalService.java    |  12 +-
 .../main/resources/libpty/freebsd/x86/libpty.so    | Bin 9978 -> 0 bytes
 .../main/resources/libpty/freebsd/x86_64/libpty.so | Bin 12370 -> 0 bytes
 .../main/resources/libpty/linux/ppc64le/libpty.so  | Bin 72560 -> 0 bytes
 .../src/main/resources/libpty/linux/x86/libpty.so  | Bin 10221 -> 0 bytes
 .../main/resources/libpty/linux/x86_64/libpty.so   | Bin 13388 -> 0 bytes
 .../main/resources/libpty/macosx/x86/libpty.dylib  | Bin 14156 -> 0 bytes
 .../resources/libpty/macosx/x86_64/libpty.dylib    | Bin 14264 -> 0 bytes
 .../main/resources/libpty/win/x86/winpty-agent.exe | Bin 601624 -> 0 bytes
 shell/src/main/resources/libpty/win/x86/winpty.dll | Bin 524808 -> 0 bytes
 .../main/resources/libpty/win/x86_64/cyglaunch.exe | Bin 15360 -> 0 bytes
 .../resources/libpty/win/x86_64/winpty-agent.exe   | Bin 749592 -> 0 bytes
 .../main/resources/libpty/win/x86_64/winpty.dll    | Bin 656392 -> 0 bytes
 .../main/resources/libpty/win/xp/winpty-agent.exe  | Bin 601624 -> 0 bytes
 shell/src/main/resources/libpty/win/xp/winpty.dll  | Bin 524808 -> 0 bytes
 19 files changed, 3 insertions(+), 523 deletions(-)

diff --git a/shell/HTERM.md b/shell/HTERM.md
deleted file mode 100644
index f967176f22..0000000000
--- a/shell/HTERM.md
+++ /dev/null
@@ -1,197 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-Original link: https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm
-
-# Embedding hterm
-
-
-This is a quick overview describing how to use hterm in your own application. 
Please direct any questions to the [chromium-hterm mailing 
list](https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-hterm).
-
-## Get the code
-
-The “libapps” git repository contains hterm and its dependencies. Clone this 
repo into a parent directory of your choice. In this example we'll create 
`~/src/libapps/`:
-
-```
-$ mkdir ~/src
-$ cd ~/src
-$ git clone https://chromium.googlesource.com/apps/libapps
-```
-
-## Build hterm
-
-The build process bundles some resources as JavaScript source and concatenates 
the JavaScript into a single file (`hterm_all.js`).
-
-```
-$ cd ~/src/libapps
-$ ./hterm/bin/mkdist.sh
-```
-
-The files are all written to `./hterm/dist/js/`. Copy the `hterm_all.js` file 
into your project.
-
-## Include hterm in your app
-
-Include the generated `hterm_all.js` file in your app in an appropriate 
manner. This step should be self evident.
-
-## Initialize hterm
-
-### Terminal node
-
-You'll want a sacrificial DOM node which will become the terminal widget. It 
should be a div which is either `position: relative` or `position: absolute`.
-
-In our example, we'll assume this DOM:
-
-```
-<!DOCTYPE html>
-<html>
-  <body>
-    <div id="terminal"
-         style="position:relative; width:100%; height:100%"></div>
-  </body>
-</html>
-```
-
-### Runtime storage
-
-You'll need to choose a storage implementation. This is the backing store that 
hterm will use to read and write preferences. This should be one of:
-
-```
-// If you are a cross-browser web app and want to use window.localStorage.
-hterm.defaultStorage = new lib.Storage.Local();
-
-// If you are a cross-browser web app and want in-memory storage only.
-hterm.defaultStorage = new lib.Storage.Memory();
-
-// If you are a Chrome app and want sync storage.
-hterm.defaultStorage = new lib.Storage.Chrome(chrome.storage.sync);
-
-// If you are a Chrome app and want local storage.
-hterm.defaultStorage = new lib.Storage.Chrome(chrome.storage.local);
-```
-
-### Framework initialization
-
-Before using hterm, you'll need to initialize the underlying libdot framework. 
You do this by calling `lib.init` and passing it your initialization callback.
-
-```
-function setupHterm() {
-  ... your hterm initialization logic ...
-}
-
-// This will be whatever normal entry/initialization point your project uses.
-window.onload = function() {
-  lib.init(setupHterm);
-};
-```
-
-### Terminal initialization
-
-All of the logic below lives within the `setupHterm` callback.
-
-Create an instance of `hterm.Terminal`:
-
-```
-// opt_profileName is the name of the terminal profile to load, or "default" if
-// not specified.  If you're using one of the persistent storage
-// implementations then this will scope all preferences read/writes to this
-// name.
-const t = new hterm.Terminal(opt_profileName);
-```
-
-Now write an `onTerminalReady` handler. This will fire once, when the terminal 
is initialized and ready for use.
-
-```
-t.onTerminalReady = function() {
-  // Create a new terminal IO object and give it the foreground.
-  // (The default IO object just prints warning messages about unhandled
-  // things to the the JS console.)
-  const io = t.io.push();
-
-  io.onVTKeystroke = (str) => {
-    // Do something useful with str here.
-    // For example, Secure Shell forwards the string onto the NaCl plugin.
-  };
-
-  io.sendString = (str) => {
-    // Just like a keystroke, except str was generated by the terminal itself.
-    // For example, when the user pastes a string.
-    // Most likely you'll do the same thing as onVTKeystroke.
-  };
-
-  io.onTerminalResize = (columns, rows) => {
-    // React to size changes here.
-    // Secure Shell pokes at NaCl, which eventually results in
-    // some ioctls on the host.
-  };
-
-  // You can call io.push() to foreground a fresh io context, which can
-  // be uses to give control of the terminal to something else.  When that
-  // thing is complete, should call io.pop() to restore control to the
-  // previous io object.
-};
-```
-
-After you've registered your onTerminalReady handler you can connect the 
terminal to the sacrificial DOM node.
-
-```
-t.decorate(document.querySelector('#terminal'));
-```
-
-### Keyboard setup
-
-After you call the `decorate` helper, you'll usually call `installKeyboard` to 
capture all keyboard input when the terminal is focused. This allows us to 
react to keyboard shortcuts and such.
-
-```
-t.installKeyboard();
-```
-
-## Write to the terminal
-
-Once `onTerminalReady` finishes, you're free to start writing content! This is 
the process or connection that wants to display content to the user (rather 
than the user sending content).
-
-```
-t.io.print('Print a string without a newline');
-t.io.println('Print a string and add CRLF');
-```
-
-You usually want to go through the `io` object to display content rather than 
going directly through the terminal. It will take care of encoding UTF-16 to 
UTF-8 and then sending it via `t.interpret` (which processes escape sequences). 
If you use the `t.print` function directly, it won't do either of those things, 
which might be what you want.
-
-## Encoding
-
-Modern applications need to make sure they handle data encoding properly at 
all times lest we end up with 
[Mojibake](https://en.wikipedia.org/wiki/Mojibake) everywhere. All data going 
in & out of hterm is via the `hterm.Terminal.IO` object (which may be accessed 
via `t.io` in the code snippets above).
-
-### hterm->app
-
-When hterm passes data to the application (via the `onVTKeystroke` and 
`sendString` callbacks), it uses [UTF-16](https://en.wikipedia.org/wiki/UTF-16) 
in native JavaScript strings. The application should then convert it to 
whatever encoding it expects.
-
-A common example when working with 
[WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) 
is to convert the string to an 
[ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBuffer) 
with [UTF-8](https://en.wikipedia.org/wiki/UTF-8) encoding. This is easily 
accomplished with the 
[TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) API.
-
-```
-const encoder = new TextEncoder();
-const ws = new WebSocket(...);
-...
-  io.onVTKeystroke = (str) => {
-    ws.send(encoder.encode(str));
-  };
-```
-
-Note: <=hterm-1.83 offered a `send-encoding` preference where you could select 
between `utf-8` and `raw` settings. The `utf-8` mode would encode 
[UTF-8](https://en.wikipedia.org/wiki/UTF-8) [code 
unit](https://en.wikipedia.org/wiki/Character_encoding)s into a JS 
[UTF-16](https://en.wikipedia.org/wiki/UTF-16) string while the `raw` mode 
would pass through the [UTF-16](https://en.wikipedia.org/wiki/UTF-16) string 
unmodified. With >=hterm-1.84, the `send-encoding` preference has been droppe 
[...]
-
-### app->hterm
-
-When passing data to hterm to interpret, strings should be in 
[UTF-16](https://en.wikipedia.org/wiki/UTF-16) encoding. This covers 
`hterm.Terminal.IO`'s `print`, `writeUTF16`, `println`, and `writelnUTF16` APIs 
as well as `hterm.Terminal`'s `interpret`.
-
-A few APIs are also provided to pass in 
[UTF-16](https://en.wikipedia.org/wiki/UTF-16) strings with 
[UTF-8](https://en.wikipedia.org/wiki/UTF-8) [code 
unit](https://en.wikipedia.org/wiki/Character_encoding)s, but those are 
deprecated and should be avoided. This covers `hterm.Terminal.IO`'s `writeUTF8` 
and `writelnUTF8` APIs.
-
-Note: <=hterm-1.84 required `hterm.Terminal.interpret`'s argument to be a 
string of [UTF-8](https://en.wikipedia.org/wiki/UTF-8) [code 
unit](https://en.wikipedia.org/wiki/Character_encoding)s when the 
`receive-encoding` was set to `utf-8`. With >=hterm-1.85, 
`hterm.Terminal.interpret` always uses 
[UTF-16](https://en.wikipedia.org/wiki/UTF-16) strings.
diff --git a/shell/PTY4J.md b/shell/PTY4J.md
deleted file mode 100644
index cb07476510..0000000000
--- a/shell/PTY4J.md
+++ /dev/null
@@ -1,135 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-Original link: https://github.com/JetBrains/pty4j
-
-# Pty4J - Pseudo terminal(PTY) implementation in Java.
-
-[![official JetBrains 
project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
-
-
-[![Build 
Status](https://travis-ci.com/traff/pty4j.svg?branch=master)](https://travis-ci.com/JetBrains/pty4j)
-
-This is a Java implementation of PTY. Written in JNA with native code to make 
fork of a process.
-
-It is based on two projects that provide the same functionality: 
[JPty](https://github.com/jawi/JPty)
-and [elt](https://code.google.com/p/elt/).
-
-While JPty is pretty good and written using only JNA it suffers from a
-hang on Mac OS X when Java is under debug 
(https://github.com/jawi/JPty/issues/2), because
-fork doesn't work well in java.
-
-elt works ok, but it has mostly native code(using JNI).
-
-So this one is a mix of the other two: a port of elt to JNA in the style it is 
made in JPty with only
-fork and process exec written in native.
-
-Also pty4j implements java interface for pty for windows, using 
[WinPty](https://github.com/rprichard/winpty) library.
-
-## Dependencies
-
-This library depends on JTermios, part of the PureJavaComm library found at
-<https://github.com/nyholku/purejavacomm>. Pty4j depends on the version of 
PureJavaComm,
-not uploaded to [the maven 
central](https://search.maven.org/artifact/com.github.purejavacomm/purejavacomm).
-It'a available as 
[org.jetbrains.pty4j:purejavacomm](https://bintray.com/jetbrains/pty4j/org.jetbrains.pty4j%3Apurejavacomm).
-
-Windows pty implementation used here is the magnificent WinPty library written 
by Ryan Prichard: https://github.com/rprichard/winpty
-
-## Adding Pty4J to your build
-
-The releases are uploaded to 
[org.jetbrains.pty4j:pty4j](https://bintray.com/jetbrains/pty4j/org.jetbrains.pty4j%3Apty4j).
-Please click on the "Set Me Up!" button there and follow the instructions.
-
-### Maven
-
-```
-  <dependencies>
-    <dependency>
-      <groupId>org.jetbrains.pty4j</groupId>
-      <artifactId>pty4j</artifactId>
-      <version>0.8.6</version>
-    </dependency>
-  </dependencies>
-
-  <repositories>
-    <repository>
-      <id>bintray-jetbrains-pty4j</id>
-      <name>bintray</name>
-      <url>https://jetbrains.bintray.com/pty4j</url>
-    </repository>
-  </repositories>
-```
-
-### Gradle
-
-```
-repositories {
-  maven {
-    url  "https://jetbrains.bintray.com/pty4j";
-  }
-}
-
-// or use jcenter
-// repositories {
-//   jcenter()
-// }
-
-dependencies {
-    compile 'org.jetbrains.pty4j:pty4j:0.8.6'
-}
-```
-
-## Usage
-
-Using this library is relatively easy:
-
-    // The command to run in a PTY...
-    String[] cmd = { "/bin/sh", "-l" };
-    // The initial environment to pass to the PTY child process...
-    String[] env = { "TERM=xterm" };
-
-    PtyProcess pty = PtyProcess.exec(cmd, env);
-
-    OutputStream os = pty.getOutputStream();
-    InputStream is = pty.getInputStream();
-
-    // ... work with the streams ...
-
-    // wait until the PTY child process terminates...
-    int result = pty.waitFor();
-
-    // free up resources.
-    pty.close();
-
-The operating systems currently supported by pty4j are: Linux, OSX and
-Windows.
-
-**Note that this library is not yet fully tested on all platforms.**
-
-## Changes
-
-    0.8 | 28-08-2018 | Native binaries are bundled into pty4j.jar
-    0.7 | 14-06-2016 | Updated to match the new winpty API
-    0.6 | 08-02-2016 | Correct NamedPipe usage for winpty
-                       FreeBSD support
-    0.5 | 28-09-2015 | Supports JNA 4.1, Cygwin support, fixes
-    0.4 | 13-01-2015 | Fixes
-    0.3 | 16-08-2013 | Native code for fork and process exec.
-    0.2 | 03-08-2013 | Linux and Windows supported.
-    0.1 | 20-07-2013 | Initial version.
-
-## License
-
-The code in this library is licensed under Eclipse Public License, version
-1.0 and can be found online at: <http://www.eclipse.org/legal/epl-v10.html>.
diff --git a/shell/pom.xml b/shell/pom.xml
index 66fdb37868..c5c4db0bf4 100644
--- a/shell/pom.xml
+++ b/shell/pom.xml
@@ -35,7 +35,7 @@
     <interpreter.name>sh</interpreter.name>
 
     <!--library versions -->
-    <pty4j.version>0.9.3</pty4j.version>
+    <pty4j.version>0.12.10-jdk8</pty4j.version>
     <jinjava.version>2.4.0</jinjava.version>
     <guava.version>32.0.0-jre</guava.version>
   </properties>
diff --git 
a/shell/src/main/java/org/apache/zeppelin/shell/terminal/helper/IOHelper.java 
b/shell/src/main/java/org/apache/zeppelin/shell/terminal/helper/IOHelper.java
deleted file mode 100644
index d0349d75c5..0000000000
--- 
a/shell/src/main/java/org/apache/zeppelin/shell/terminal/helper/IOHelper.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zeppelin.shell.terminal.helper;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class IOHelper {
-  private static final Logger LOGGER = LoggerFactory.getLogger(IOHelper.class);
-
-  public static void close(Closeable... closables) {
-    for (Closeable closable : closables) {
-      try {
-        closable.close();
-      } catch (Exception e) {
-        LOGGER.error(e.getMessage(), e);
-      }
-    }
-  }
-
-  public static synchronized void copyLibPty(Path dataDir) throws IOException {
-    Path donePath = dataDir.resolve(".DONE");
-
-    if (Files.exists(donePath)) {
-      return;
-    }
-
-    String jarPath = getClassPath(IOHelper.class) + File.separator;
-    Set<String> nativeFiles = getNativeFiles();
-    for (String nativeFile : nativeFiles) {
-      Path nativePath = dataDir.resolve(nativeFile);
-
-      if (Files.notExists(nativePath)) {
-        Files.createDirectories(nativePath.getParent());
-        InputStream inputStream = IOHelper.class.getResourceAsStream("/" + 
nativeFile);
-        if (null == inputStream) {
-          Path source = Paths.get(jarPath + nativeFile);
-          if (!Files.exists(source)) {
-            throw new IOException("Can't find pytlib file : " + jarPath + 
nativeFile);
-          } else {
-            LOGGER.info("Use the pytlib file {} outside the JAR package.", 
jarPath + nativeFile);
-          }
-          Files.copy(source, nativePath);
-        } else {
-          LOGGER.info("Use the libpty file {} in the JAR package resource.", 
nativeFile);
-          Files.copy(inputStream, nativePath);
-          close(inputStream);
-        }
-      }
-    }
-
-    Files.createFile(donePath);
-  }
-
-  private static Set<String> getNativeFiles() {
-    final Set<String> nativeFiles = new HashSet<>();
-
-    List<String> freebsd = Arrays.asList(
-        "libpty/freebsd/x86/libpty.so", "libpty/freebsd/x86_64/libpty.so");
-    List<String> linux = Arrays.asList(
-        "libpty/linux/x86/libpty.so", "libpty/linux/x86_64/libpty.so");
-    List<String> macosx = Arrays.asList(
-        "libpty/macosx/x86/libpty.dylib", "libpty/macosx/x86_64/libpty.dylib");
-    List<String> win_x86 = Arrays.asList(
-        "libpty/win/x86/winpty.dll", "libpty/win/x86/winpty-agent.exe");
-    List<String> win_x86_64 = Arrays.asList(
-        "libpty/win/x86_64/winpty.dll", "libpty/win/x86_64/winpty-agent.exe",
-        "libpty/win/x86_64/cyglaunch.exe");
-    List<String> win_xp = Arrays.asList(
-        "libpty/win/xp/winpty.dll", "libpty/win/xp/winpty-agent.exe");
-
-    nativeFiles.addAll(freebsd);
-    nativeFiles.addAll(linux);
-    nativeFiles.addAll(macosx);
-    nativeFiles.addAll(win_x86);
-    nativeFiles.addAll(win_x86_64);
-    nativeFiles.addAll(win_xp);
-
-    return nativeFiles;
-  }
-
-  private static String getClassPath(Class clazz) throws 
UnsupportedEncodingException {
-    // Check if the parameters passed in by the user are empty
-    if (clazz == null) {
-      throw new java.lang.IllegalArgumentException("The parameter cannot be 
empty!");
-    }
-
-    ClassLoader loader = clazz.getClassLoader();
-    // Get the full name of the class, including the package name
-    String clsName = clazz.getName() + ".class";
-    // Get the package where the incoming parameters are located
-    Package pack = clazz.getPackage();
-    String path = "";
-    // If not an anonymous package, convert the package name to a path
-    if (pack != null) {
-      String packName = pack.getName();
-      // Here is a simple decision to determine whether it is a Java base 
class library,
-      // preventing users from passing in the JDK built-in class library.
-      if (packName.startsWith("java.") || packName.startsWith("javax.")) {
-        throw new java.lang.IllegalArgumentException("Do not transfer system 
classes!");
-      }
-
-      // In the name of the class, remove the part of the package name
-      // and get the file name of the class.
-      clsName = clsName.substring(packName.length() + 1);
-      // Determine whether the package name is a simple package name, and if 
so,
-      // directly convert the package name to a path.
-      if (packName.indexOf(".") < 0) {
-        path = packName + "/";
-      } else {
-        // Otherwise, the package name is converted to a path according
-        // to the component part of the package name.
-        int start = 0, end = 0;
-        end = packName.indexOf(".");
-        while (end != -1) {
-          path = path + packName.substring(start, end) + "/";
-          start = end + 1;
-          end = packName.indexOf(".", start);
-        }
-        path = path + packName.substring(start) + "/";
-      }
-    }
-    // Call the classReloader's getResource method, passing in the
-    // class file name containing the path information.
-    java.net.URL url = loader.getResource(path + clsName);
-    // Get path information from the URL object
-    String realPath = url.getPath();
-    // Remove the protocol name "file:" in the path information.
-    int pos = realPath.indexOf("file:");
-    if (pos > -1) {
-      realPath = realPath.substring(pos + 5);
-    }
-    // Remove the path information and the part that contains the class file 
information,
-    // and get the path where the class is located.
-    pos = realPath.indexOf(path + clsName);
-    realPath = realPath.substring(0, pos - 1);
-    // If the class file is packaged into a JAR file, etc.,
-    // remove the corresponding JAR and other package file names.
-    if (realPath.endsWith("!")) {
-      realPath = realPath.substring(0, realPath.lastIndexOf("/"));
-    }
-
-    try {
-      realPath = java.net.URLDecoder.decode(realPath, "utf-8");
-    } catch (UnsupportedEncodingException e) {
-      LOGGER.error(e.getMessage(), e);
-    }
-
-    return realPath;
-  }
-
-}
diff --git 
a/shell/src/main/java/org/apache/zeppelin/shell/terminal/service/TerminalService.java
 
b/shell/src/main/java/org/apache/zeppelin/shell/terminal/service/TerminalService.java
index bdc5762cee..f7d3c13f9d 100644
--- 
a/shell/src/main/java/org/apache/zeppelin/shell/terminal/service/TerminalService.java
+++ 
b/shell/src/main/java/org/apache/zeppelin/shell/terminal/service/TerminalService.java
@@ -19,9 +19,9 @@ package org.apache.zeppelin.shell.terminal.service;
 
 import com.google.gson.Gson;
 import com.pty4j.PtyProcess;
+import com.pty4j.PtyProcessBuilder;
 import com.pty4j.WinSize;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.zeppelin.shell.terminal.helper.IOHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,8 +31,6 @@ import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
@@ -69,10 +67,6 @@ public class TerminalService {
   private void initializeProcess() throws Exception {
     LOGGER.info("initialize TerminalService Process");
 
-    String userHome = System.getProperty("user.home");
-    Path dataDir = Paths.get(userHome).resolve(".terminalfx");
-    IOHelper.copyLibPty(dataDir);
-
     boolean isWindows = System.getProperty("os.name").startsWith("Windows");
     if (isWindows) {
       this.termCommand = "cmd.exe".split("\\s+");
@@ -83,9 +77,7 @@ public class TerminalService {
     Map<String, String> envs = new HashMap<>(System.getenv());
     envs.put("TERM", "xterm");
 
-    System.setProperty("PTY_LIB_FOLDER", dataDir.resolve("libpty").toString());
-
-    this.process = PtyProcess.exec(termCommand, envs, userHome);
+    this.process = new 
PtyProcessBuilder().setCommand(termCommand).setEnvironment(envs).start();
 
     process.setWinSize(new WinSize(columns, rows));
     this.inputReader = new BufferedReader(new 
InputStreamReader(process.getInputStream()));
diff --git a/shell/src/main/resources/libpty/freebsd/x86/libpty.so 
b/shell/src/main/resources/libpty/freebsd/x86/libpty.so
deleted file mode 100755
index 962272cae7..0000000000
Binary files a/shell/src/main/resources/libpty/freebsd/x86/libpty.so and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/freebsd/x86_64/libpty.so 
b/shell/src/main/resources/libpty/freebsd/x86_64/libpty.so
deleted file mode 100755
index 8a0b896b88..0000000000
Binary files a/shell/src/main/resources/libpty/freebsd/x86_64/libpty.so and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/linux/ppc64le/libpty.so 
b/shell/src/main/resources/libpty/linux/ppc64le/libpty.so
deleted file mode 100755
index 37966c3067..0000000000
Binary files a/shell/src/main/resources/libpty/linux/ppc64le/libpty.so and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/linux/x86/libpty.so 
b/shell/src/main/resources/libpty/linux/x86/libpty.so
deleted file mode 100644
index 6bfa7bfcfe..0000000000
Binary files a/shell/src/main/resources/libpty/linux/x86/libpty.so and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/linux/x86_64/libpty.so 
b/shell/src/main/resources/libpty/linux/x86_64/libpty.so
deleted file mode 100644
index 4c3a87c3f0..0000000000
Binary files a/shell/src/main/resources/libpty/linux/x86_64/libpty.so and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/macosx/x86/libpty.dylib 
b/shell/src/main/resources/libpty/macosx/x86/libpty.dylib
deleted file mode 100644
index cf48e925e7..0000000000
Binary files a/shell/src/main/resources/libpty/macosx/x86/libpty.dylib and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/macosx/x86_64/libpty.dylib 
b/shell/src/main/resources/libpty/macosx/x86_64/libpty.dylib
deleted file mode 100644
index 1427ea07f5..0000000000
Binary files a/shell/src/main/resources/libpty/macosx/x86_64/libpty.dylib and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/win/x86/winpty-agent.exe 
b/shell/src/main/resources/libpty/win/x86/winpty-agent.exe
deleted file mode 100644
index 29355980dd..0000000000
Binary files a/shell/src/main/resources/libpty/win/x86/winpty-agent.exe and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/win/x86/winpty.dll 
b/shell/src/main/resources/libpty/win/x86/winpty.dll
deleted file mode 100755
index 9379c9c1d0..0000000000
Binary files a/shell/src/main/resources/libpty/win/x86/winpty.dll and /dev/null 
differ
diff --git a/shell/src/main/resources/libpty/win/x86_64/cyglaunch.exe 
b/shell/src/main/resources/libpty/win/x86_64/cyglaunch.exe
deleted file mode 100644
index d84e6e964c..0000000000
Binary files a/shell/src/main/resources/libpty/win/x86_64/cyglaunch.exe and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/win/x86_64/winpty-agent.exe 
b/shell/src/main/resources/libpty/win/x86_64/winpty-agent.exe
deleted file mode 100644
index b5abdeee38..0000000000
Binary files a/shell/src/main/resources/libpty/win/x86_64/winpty-agent.exe and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/win/x86_64/winpty.dll 
b/shell/src/main/resources/libpty/win/x86_64/winpty.dll
deleted file mode 100644
index 208cef3e3b..0000000000
Binary files a/shell/src/main/resources/libpty/win/x86_64/winpty.dll and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/win/xp/winpty-agent.exe 
b/shell/src/main/resources/libpty/win/xp/winpty-agent.exe
deleted file mode 100755
index f78a0658a2..0000000000
Binary files a/shell/src/main/resources/libpty/win/xp/winpty-agent.exe and 
/dev/null differ
diff --git a/shell/src/main/resources/libpty/win/xp/winpty.dll 
b/shell/src/main/resources/libpty/win/xp/winpty.dll
deleted file mode 100755
index 098ecae378..0000000000
Binary files a/shell/src/main/resources/libpty/win/xp/winpty.dll and /dev/null 
differ


Reply via email to