@@ -0,0 +1,2963 @@
+/**%0A * Copyright (C) 2015 Red Hat, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *         http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.fabric8.kubernetes.examples;%0A%0Aimport io.fabric8.kubernetes.client.Config;%0Aimport io.fabric8.kubernetes.client.ConfigBuilder;%0Aimport io.fabric8.kubernetes.client.DefaultKubernetesClient;%0Aimport io.fabric8.kubernetes.client.KubernetesClient;%0Aimport io.fabric8.kubernetes.client.dsl.ExecListener;%0Aimport io.fabric8.kubernetes.client.dsl.ExecWatch;%0Aimport okhttp3.Response;%0A%0Apublic class ExecExampleWithTerminalSize %7B%0A%0A    public static void main(String%5B%5D args) throws InterruptedException %7B%0A        if (args.length %3C 1) %7B%0A            System.out.println(%22Usage: podName %5Bmaster%5D %5Bnamespace%5D %5Bcolumns%5D %5Blines%5D%5Cn%22 +%0A              %22Use env variable COLUMNS & LINES to initialize terminal size.%22);%0A            return;%0A          %7D%0A%0A        String podName = args%5B0%5D;%0A        String namespace = %22default%22;%0A        String master = %22https://localhost:8443/%22;%0A        String columns = %2280%22;%0A        String lines = %2224%22;%0A%0A        if (args.length %3E 1) %7B%0A            master = args%5B1%5D;%0A          %7D%0A          if (args.length %3E 2) %7B%0A            namespace = args%5B2%5D;%0A            if (args.length %3E 3) %7B%0A              columns = args%5B3%5D;%0A              if (args.length %3E 4) %7B%0A                lines = args%5B4%5D;%0A              %7D%0A            %7D%0A          %7D%0A%0A        Config config = new ConfigBuilder().withMasterUrl(master).build();%0A        try (final KubernetesClient client = new DefaultKubernetesClient(config);%0A             ExecWatch watch = client.pods().inNamespace(namespace).withName(podName)%0A                .readingInput(System.in)%0A                .writingOutput(System.out)%0A                .writingError(System.err)%0A                .withTTY()%0A                .usingListener(new SimpleListener())%0A                .exec(%22env%22, %22TERM%253Dxterm%22, %22COLUMNS%253D%22 + columns, %22LINES%253D%22 + lines, %22bash%22))%7B%0A%0A            Thread.sleep(10 * 1000);%0A        %7D%0A    %7D%0A%0A    private static class SimpleListener implements ExecListener %7B%0A%0A        @Override%0A        public void onOpen(Response response) %7B%0A            System.out.println(%22The shell will remain open for 10 seconds.%22);%0A        %7D%0A%0A        @Override%0A        public void onFailure(Throwable t, Response response) %7B%0A            System.err.println(%22shell barfed%22);%0A        %7D%0A%0A        @Override%0A        public void onClose(int code, String reason) %7B%0A            System.out.println(%22The shell will now close.%22);%0A        %7D%0A    %7D%0A%0A%7D%0A

Add workaround to initialize terminal size while execute bash with tty.