You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by greghogan <gi...@git.apache.org> on 2017/05/31 13:16:28 UTC

[GitHub] flink pull request #4029: [FLINK-6777] [shell] Activate strict checkstyle

GitHub user greghogan opened a pull request:

    https://github.com/apache/flink/pull/4029

    [FLINK-6777] [shell] Activate strict checkstyle

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/greghogan/flink 6777_activate_strict_checkstyle_for_flink_scala_shell

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/4029.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4029
    
----
commit 4846bf07420f66eb4c43e288eaa031178468676e
Author: Greg Hogan <co...@greghogan.com>
Date:   2017-05-30T19:21:19Z

    [FLINK-6777] [shell] Activate strict checkstyle

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4029: [FLINK-6777] [shell] Activate strict checkstyle

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4029#discussion_r119376183
  
    --- Diff: flink-scala-shell/src/main/java/org/apache/flink/api/java/JarHelper.java ---
    @@ -71,144 +71,151 @@ public JarHelper() {}
     	public void jarDir(File dirOrFile2Jar, File destJar)
     		throws IOException {
     
    -	if (dirOrFile2Jar == null || destJar == null)
    -	{
    -		throw new IllegalArgumentException();
    -	}
    +		if (dirOrFile2Jar == null || destJar == null) {
    +			throw new IllegalArgumentException();
    +		}
     
    -	mDestJarName = destJar.getCanonicalPath();
    -	FileOutputStream fout = new FileOutputStream(destJar);
    -	JarOutputStream jout = new JarOutputStream(fout);
    -	//jout.setLevel(0);
    -	try {
    -		jarDir(dirOrFile2Jar, jout, null);
    -	} catch(IOException ioe) {
    -		throw ioe;
    -	} finally {
    -		jout.close();
    -		fout.close();
    -	}
    +		mDestJarName = destJar.getCanonicalPath();
    +		FileOutputStream fout = new FileOutputStream(destJar);
    +		JarOutputStream jout = new JarOutputStream(fout);
    +		//jout.setLevel(0);
    +		try {
    +			jarDir(dirOrFile2Jar, jout, null);
    +		} catch (IOException ioe) {
    +			throw ioe;
    +		} finally {
    +			jout.close();
    +			fout.close();
    +		}
     	}
     
     	/**
     	 * Unjars a given jar file into a given directory.
     	 */
     	public void unjarDir(File jarFile, File destDir) throws IOException {
    -	BufferedOutputStream dest = null;
    -	FileInputStream fis = new FileInputStream(jarFile);
    -	unjar(fis, destDir);
    +		BufferedOutputStream dest = null;
    +		FileInputStream fis = new FileInputStream(jarFile);
    +		unjar(fis, destDir);
     	}
     
     	/**
     	 * Given an InputStream on a jar file, unjars the contents into the given
     	 * directory.
     	 */
     	public void unjar(InputStream in, File destDir) throws IOException {
    -	BufferedOutputStream dest = null;
    -	JarInputStream jis = new JarInputStream(in);
    -	JarEntry entry;
    -	while ((entry = jis.getNextJarEntry()) != null) {
    -		if (entry.isDirectory()) {
    -		File dir = new File(destDir,entry.getName());
    -		dir.mkdir();
    -		if (entry.getTime() != -1) {dir.setLastModified(entry.getTime());}
    -		continue;
    -		}
    -		int count;
    -		byte[] data = new byte[ BUFFER_SIZE ];
    -		File destFile = new File(destDir, entry.getName());
    -		if (mVerbose) {
    -			System.out.println("unjarring " + destFile +
    +		BufferedOutputStream dest = null;
    +		JarInputStream jis = new JarInputStream(in);
    +		JarEntry entry;
    +		while ((entry = jis.getNextJarEntry()) != null) {
    +			if (entry.isDirectory()) {
    +				File dir = new File(destDir, entry.getName());
    +				dir.mkdir();
    +				if (entry.getTime() != -1) {
    +					dir.setLastModified(entry.getTime());
    +				}
    +				continue;
    +			}
    +			int count;
    +			byte[] data = new byte[BUFFER_SIZE];
    +			File destFile = new File(destDir, entry.getName());
    +			if (mVerbose) {
    +				System.out.println("unjarring " + destFile +
     					" from " + entry.getName());
    -		}
    -		FileOutputStream fos = new FileOutputStream(destFile);
    -		dest = new BufferedOutputStream(fos, BUFFER_SIZE);
    -		try {
    -			while ((count = jis.read(data, 0, BUFFER_SIZE)) != -1) {
    -				dest.write(data, 0, count);
     			}
    -			dest.flush();
    -		} finally {
    -			dest.close();
    +			FileOutputStream fos = new FileOutputStream(destFile);
    +			dest = new BufferedOutputStream(fos, BUFFER_SIZE);
    +			try {
    +				while ((count = jis.read(data, 0, BUFFER_SIZE)) != -1) {
    +					dest.write(data, 0, count);
    +				}
    +				dest.flush();
    +			} finally {
    +				dest.close();
    +			}
    +			if (entry.getTime() != -1) {
    +				destFile.setLastModified(entry.getTime());
    +			}
     		}
    -		if (entry.getTime() != -1) {destFile.setLastModified(entry.getTime());}
    -	}
    -	jis.close();
    +		jis.close();
     	}
     
     	public void setVerbose(boolean b) {
    -	mVerbose = b;
    +		mVerbose = b;
     	}
     
     	// ========================================================================
     	// Private methods
     
     	private static final char SEP = '/';
    +
     	/**
     	 * Recursively jars up the given path under the given directory.
     	 */
     	private void jarDir(File dirOrFile2jar, JarOutputStream jos, String path)
     		throws IOException {
    -	if (mVerbose) { System.out.println("checking " + dirOrFile2jar);}
    -	if (dirOrFile2jar.isDirectory()) {
    -		String[] dirList = dirOrFile2jar.list();
    -		String subPath = (path == null) ? "" : (path+dirOrFile2jar.getName()+SEP);
    -		if (path != null) {
    -		JarEntry je = new JarEntry(subPath);
    -		je.setTime(dirOrFile2jar.lastModified());
    -		jos.putNextEntry(je);
    -		jos.flush();
    -		jos.closeEntry();
    -		}
    -		for (int i = 0; i < dirList.length; i++) {
    -		File f = new File(dirOrFile2jar, dirList[i]);
    -		jarDir(f,jos,subPath);
    -		}
    -	} else if (dirOrFile2jar.exists()) {
    -		if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName))
    -		{
    -		if (mVerbose) {System.out.println("skipping " + dirOrFile2jar.getPath());}
    -		return;
    -		}
    -
     		if (mVerbose) {
    -			System.out.println("adding " + dirOrFile2jar.getPath());
    +			System.out.println("checking " + dirOrFile2jar);
     		}
    -		FileInputStream fis = new FileInputStream(dirOrFile2jar);
    -		try {
    -		JarEntry entry = new JarEntry(path+dirOrFile2jar.getName());
    -		entry.setTime(dirOrFile2jar.lastModified());
    -		jos.putNextEntry(entry);
    -		while ((mByteCount = fis.read(mBuffer)) != -1) {
    -			jos.write(mBuffer, 0, mByteCount);
    -			if (mVerbose) { System.out.println("wrote " + mByteCount + " bytes");}
    -		}
    -		jos.flush();
    -		jos.closeEntry();
    -		} catch (IOException ioe) {
    -		throw ioe;
    -		} finally {
    -		fis.close();
    +		if (dirOrFile2jar.isDirectory()) {
    +			String[] dirList = dirOrFile2jar.list();
    +			String subPath = (path == null) ? "" : (path + dirOrFile2jar.getName() + SEP);
    +			if (path != null) {
    +				JarEntry je = new JarEntry(subPath);
    +				je.setTime(dirOrFile2jar.lastModified());
    +				jos.putNextEntry(je);
    +				jos.flush();
    +				jos.closeEntry();
    +			}
    +			for (int i = 0; i < dirList.length; i++) {
    +				File f = new File(dirOrFile2jar, dirList[i]);
    +				jarDir(f, jos, subPath);
    +			}
    +		} else if (dirOrFile2jar.exists()) {
    +			if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName)) {
    +				if (mVerbose) {
    +					System.out.println("skipping " + dirOrFile2jar.getPath());
    +				}
    +				return;
    +			}
    +
    +			if (mVerbose) {
    +				System.out.println("adding " + dirOrFile2jar.getPath());
    +			}
    +			FileInputStream fis = new FileInputStream(dirOrFile2jar);
    +			try {
    +				JarEntry entry = new JarEntry(path + dirOrFile2jar.getName());
    +				entry.setTime(dirOrFile2jar.lastModified());
    +				jos.putNextEntry(entry);
    +				while ((mByteCount = fis.read(mBuffer)) != -1) {
    +					jos.write(mBuffer, 0, mByteCount);
    +					if (mVerbose) {
    +						System.out.println("wrote " + mByteCount + " bytes");
    +					}
    +				}
    +				jos.flush();
    +				jos.closeEntry();
    +			} catch (IOException ioe) {
    +				throw ioe;
    +			} finally {
    +				fis.close();
    +			}
     		}
     	}
    -	}
     
     	// for debugging
     	public static void main(String[] args)
    -		throws IOException
    -	{
    -	if (args.length < 2)
    -	{
    -		System.err.println("Usage: JarHelper jarname.jar directory");
    -		return;
    -	}
    +		throws IOException {
    --- End diff --
    
    Will do. Since this was copied code I had simply done an IntelliJ code reformat.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4029: [FLINK-6777] [shell] Activate strict checkstyle

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/4029


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4029: [FLINK-6777] [shell] Activate strict checkstyle

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4029#discussion_r119362077
  
    --- Diff: flink-scala-shell/src/main/java/org/apache/flink/api/java/JarHelper.java ---
    @@ -71,144 +71,151 @@ public JarHelper() {}
     	public void jarDir(File dirOrFile2Jar, File destJar)
     		throws IOException {
     
    -	if (dirOrFile2Jar == null || destJar == null)
    -	{
    -		throw new IllegalArgumentException();
    -	}
    +		if (dirOrFile2Jar == null || destJar == null) {
    +			throw new IllegalArgumentException();
    +		}
     
    -	mDestJarName = destJar.getCanonicalPath();
    -	FileOutputStream fout = new FileOutputStream(destJar);
    -	JarOutputStream jout = new JarOutputStream(fout);
    -	//jout.setLevel(0);
    -	try {
    -		jarDir(dirOrFile2Jar, jout, null);
    -	} catch(IOException ioe) {
    -		throw ioe;
    -	} finally {
    -		jout.close();
    -		fout.close();
    -	}
    +		mDestJarName = destJar.getCanonicalPath();
    +		FileOutputStream fout = new FileOutputStream(destJar);
    +		JarOutputStream jout = new JarOutputStream(fout);
    +		//jout.setLevel(0);
    +		try {
    +			jarDir(dirOrFile2Jar, jout, null);
    +		} catch (IOException ioe) {
    +			throw ioe;
    +		} finally {
    +			jout.close();
    +			fout.close();
    +		}
     	}
     
     	/**
     	 * Unjars a given jar file into a given directory.
     	 */
     	public void unjarDir(File jarFile, File destDir) throws IOException {
    -	BufferedOutputStream dest = null;
    -	FileInputStream fis = new FileInputStream(jarFile);
    -	unjar(fis, destDir);
    +		BufferedOutputStream dest = null;
    +		FileInputStream fis = new FileInputStream(jarFile);
    +		unjar(fis, destDir);
     	}
     
     	/**
     	 * Given an InputStream on a jar file, unjars the contents into the given
     	 * directory.
     	 */
     	public void unjar(InputStream in, File destDir) throws IOException {
    -	BufferedOutputStream dest = null;
    -	JarInputStream jis = new JarInputStream(in);
    -	JarEntry entry;
    -	while ((entry = jis.getNextJarEntry()) != null) {
    -		if (entry.isDirectory()) {
    -		File dir = new File(destDir,entry.getName());
    -		dir.mkdir();
    -		if (entry.getTime() != -1) {dir.setLastModified(entry.getTime());}
    -		continue;
    -		}
    -		int count;
    -		byte[] data = new byte[ BUFFER_SIZE ];
    -		File destFile = new File(destDir, entry.getName());
    -		if (mVerbose) {
    -			System.out.println("unjarring " + destFile +
    +		BufferedOutputStream dest = null;
    +		JarInputStream jis = new JarInputStream(in);
    +		JarEntry entry;
    +		while ((entry = jis.getNextJarEntry()) != null) {
    +			if (entry.isDirectory()) {
    +				File dir = new File(destDir, entry.getName());
    +				dir.mkdir();
    +				if (entry.getTime() != -1) {
    +					dir.setLastModified(entry.getTime());
    +				}
    +				continue;
    +			}
    +			int count;
    +			byte[] data = new byte[BUFFER_SIZE];
    +			File destFile = new File(destDir, entry.getName());
    +			if (mVerbose) {
    +				System.out.println("unjarring " + destFile +
     					" from " + entry.getName());
    -		}
    -		FileOutputStream fos = new FileOutputStream(destFile);
    -		dest = new BufferedOutputStream(fos, BUFFER_SIZE);
    -		try {
    -			while ((count = jis.read(data, 0, BUFFER_SIZE)) != -1) {
    -				dest.write(data, 0, count);
     			}
    -			dest.flush();
    -		} finally {
    -			dest.close();
    +			FileOutputStream fos = new FileOutputStream(destFile);
    +			dest = new BufferedOutputStream(fos, BUFFER_SIZE);
    +			try {
    +				while ((count = jis.read(data, 0, BUFFER_SIZE)) != -1) {
    +					dest.write(data, 0, count);
    +				}
    +				dest.flush();
    +			} finally {
    +				dest.close();
    +			}
    +			if (entry.getTime() != -1) {
    +				destFile.setLastModified(entry.getTime());
    +			}
     		}
    -		if (entry.getTime() != -1) {destFile.setLastModified(entry.getTime());}
    -	}
    -	jis.close();
    +		jis.close();
     	}
     
     	public void setVerbose(boolean b) {
    -	mVerbose = b;
    +		mVerbose = b;
     	}
     
     	// ========================================================================
     	// Private methods
     
     	private static final char SEP = '/';
    +
     	/**
     	 * Recursively jars up the given path under the given directory.
     	 */
     	private void jarDir(File dirOrFile2jar, JarOutputStream jos, String path)
     		throws IOException {
    -	if (mVerbose) { System.out.println("checking " + dirOrFile2jar);}
    -	if (dirOrFile2jar.isDirectory()) {
    -		String[] dirList = dirOrFile2jar.list();
    -		String subPath = (path == null) ? "" : (path+dirOrFile2jar.getName()+SEP);
    -		if (path != null) {
    -		JarEntry je = new JarEntry(subPath);
    -		je.setTime(dirOrFile2jar.lastModified());
    -		jos.putNextEntry(je);
    -		jos.flush();
    -		jos.closeEntry();
    -		}
    -		for (int i = 0; i < dirList.length; i++) {
    -		File f = new File(dirOrFile2jar, dirList[i]);
    -		jarDir(f,jos,subPath);
    -		}
    -	} else if (dirOrFile2jar.exists()) {
    -		if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName))
    -		{
    -		if (mVerbose) {System.out.println("skipping " + dirOrFile2jar.getPath());}
    -		return;
    -		}
    -
     		if (mVerbose) {
    -			System.out.println("adding " + dirOrFile2jar.getPath());
    +			System.out.println("checking " + dirOrFile2jar);
     		}
    -		FileInputStream fis = new FileInputStream(dirOrFile2jar);
    -		try {
    -		JarEntry entry = new JarEntry(path+dirOrFile2jar.getName());
    -		entry.setTime(dirOrFile2jar.lastModified());
    -		jos.putNextEntry(entry);
    -		while ((mByteCount = fis.read(mBuffer)) != -1) {
    -			jos.write(mBuffer, 0, mByteCount);
    -			if (mVerbose) { System.out.println("wrote " + mByteCount + " bytes");}
    -		}
    -		jos.flush();
    -		jos.closeEntry();
    -		} catch (IOException ioe) {
    -		throw ioe;
    -		} finally {
    -		fis.close();
    +		if (dirOrFile2jar.isDirectory()) {
    +			String[] dirList = dirOrFile2jar.list();
    +			String subPath = (path == null) ? "" : (path + dirOrFile2jar.getName() + SEP);
    +			if (path != null) {
    +				JarEntry je = new JarEntry(subPath);
    +				je.setTime(dirOrFile2jar.lastModified());
    +				jos.putNextEntry(je);
    +				jos.flush();
    +				jos.closeEntry();
    +			}
    +			for (int i = 0; i < dirList.length; i++) {
    +				File f = new File(dirOrFile2jar, dirList[i]);
    +				jarDir(f, jos, subPath);
    +			}
    +		} else if (dirOrFile2jar.exists()) {
    +			if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName)) {
    +				if (mVerbose) {
    +					System.out.println("skipping " + dirOrFile2jar.getPath());
    +				}
    +				return;
    +			}
    +
    +			if (mVerbose) {
    +				System.out.println("adding " + dirOrFile2jar.getPath());
    +			}
    +			FileInputStream fis = new FileInputStream(dirOrFile2jar);
    +			try {
    +				JarEntry entry = new JarEntry(path + dirOrFile2jar.getName());
    +				entry.setTime(dirOrFile2jar.lastModified());
    +				jos.putNextEntry(entry);
    +				while ((mByteCount = fis.read(mBuffer)) != -1) {
    +					jos.write(mBuffer, 0, mByteCount);
    +					if (mVerbose) {
    +						System.out.println("wrote " + mByteCount + " bytes");
    +					}
    +				}
    +				jos.flush();
    +				jos.closeEntry();
    +			} catch (IOException ioe) {
    +				throw ioe;
    +			} finally {
    +				fis.close();
    +			}
     		}
     	}
    -	}
     
     	// for debugging
     	public static void main(String[] args)
    -		throws IOException
    -	{
    -	if (args.length < 2)
    -	{
    -		System.err.println("Usage: JarHelper jarname.jar directory");
    -		return;
    -	}
    +		throws IOException {
    --- End diff --
    
    We could move this to the previous line


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---