java-8

replace classes from sun.security.* packages

*爱你&永不变心* 提交于 2019-12-30 08:05:32
问题 I'm trying to upgrade an app from JDK7 to JDK8 which uses the following classes from the sun.security.* packages sun.security.x509.X509CertImpl sun.security.pkcs11.SunPKCS11 sun.security.util.DerOutputStream sun.security.util.DerValue sun.security.util.ObjectIdentifier sun.security.pkcs.PKCS10 sun.security.x509.X500Name sun.security.pkcs11.SunPKCS11 sun.security.pkcs11.wrapper.CK_TOKEN_INFO sun.security.pkcs.PKCS10 The usage of these classes generates warnings in all cases except for sun

Do terminal operations on streams close the source? [duplicate]

吃可爱长大的小学妹 提交于 2019-12-30 08:03:15
问题 This question already has answers here : Do terminal operations close the stream? (2 answers) Closed 5 years ago . Consider the following code: Path directory = Paths.get(/* some directory */); Files.list(directory).forEach(System.out::println); Does a terminal operation (like forEach ) close the underlying file that has been opened? Refer to the relevant parts of the javadoc of Files.list: The returned stream encapsulates a DirectoryStream. If timely disposal of file system resources is

What is the correct way to create an already-completed CompletableFuture<Void>

允我心安 提交于 2019-12-30 07:59:10
问题 I am using Completable futures in java 8 and I want to write a method that, based on a received parameter, either runs multiple tasks with side effects in parallel and then return their "combined" future (using CompletableFuture.allOf() ), or does nothing and returns an already-completed future. However, allOf returns a CompletableFuture<Void> : public static CompletableFuture<Void> allOf(CompletableFuture<?>... cfs) And the only way to create an already-completed future that know is using

java.lang.IllegalStateException: endPosTable already set

雨燕双飞 提交于 2019-12-30 07:58:11
问题 Trying to build an alexa (amazon:echo) skills set. At the same time, trying to use this experience as a learning testbed for dependency injection through dagger 2. However, building the package using maven-2 cmd: mvn assembly:assembly -DdescriptorId=jar-with-dependencies package'. to generate a zip jar with the complete dependencies produces the following exception trace: [INFO] ------------------------------------------------------------------------ [INFO] Building Echo Device Client 1.0

java.lang.IllegalStateException: endPosTable already set

我怕爱的太早我们不能终老 提交于 2019-12-30 07:58:07
问题 Trying to build an alexa (amazon:echo) skills set. At the same time, trying to use this experience as a learning testbed for dependency injection through dagger 2. However, building the package using maven-2 cmd: mvn assembly:assembly -DdescriptorId=jar-with-dependencies package'. to generate a zip jar with the complete dependencies produces the following exception trace: [INFO] ------------------------------------------------------------------------ [INFO] Building Echo Device Client 1.0

java.lang.IllegalStateException: endPosTable already set

自古美人都是妖i 提交于 2019-12-30 07:58:03
问题 Trying to build an alexa (amazon:echo) skills set. At the same time, trying to use this experience as a learning testbed for dependency injection through dagger 2. However, building the package using maven-2 cmd: mvn assembly:assembly -DdescriptorId=jar-with-dependencies package'. to generate a zip jar with the complete dependencies produces the following exception trace: [INFO] ------------------------------------------------------------------------ [INFO] Building Echo Device Client 1.0

Comparison between legacy for loop, streams and parallelStream in Java 8

限于喜欢 提交于 2019-12-30 07:50:53
问题 import java.util.ArrayList; import java.util.List; public class IterationBenchmark { public static void main(String args[]){ List<String> persons = new ArrayList<String>(); persons.add("AAA"); persons.add("BBB"); persons.add("CCC"); persons.add("DDD"); long timeMillis = System.currentTimeMillis(); for(String person : persons) System.out.println(person); System.out.println("Time taken for legacy for loop : "+ (System.currentTimeMillis() - timeMillis)); timeMillis = System.currentTimeMillis();

Storing java 8 LocalDate in mongo DB

佐手、 提交于 2019-12-30 06:36:48
问题 Using Spring boot 1.5.4.RELEASE and Mongo driver 3.4.2 . I want to store LocalDate in mongo DB , but I am facing a weird problem. LocalDate startDate = LocalDate.now(); LocalDate endDate = LocalDate.of(2020,12,01); System.out.println("---- StartDate : ---"+startDate); System.out.println("-----End Date : ----"+endDate); repository.save(new Person("Mehraj","Malik", startDate, endDate)); Output on Console : ---- StartDate : ---2017-08-26 -----End Date : ----2020-12-01 But In MongoDb it is

Collect a Stream of Map<K,V> to Map<K,List<V>>

左心房为你撑大大i 提交于 2019-12-30 06:35:10
问题 I have a Stream< Map< K, V > > and I'm trying to merge those maps together, but preserve duplicate values in a list, so the final type would be Map< K, List<V> > . Is there a way to do this? I know the toMap collector has a binary function to basically choose which value is returned, but can it keep track of the converted list? i.e. if a is a Stream< Map< String, Int > > a.flatMap(map -> map.entrySet().stream()).collect( Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (val1, val2) ->

Storing java 8 LocalDate in mongo DB

不打扰是莪最后的温柔 提交于 2019-12-30 06:34:13
问题 Using Spring boot 1.5.4.RELEASE and Mongo driver 3.4.2 . I want to store LocalDate in mongo DB , but I am facing a weird problem. LocalDate startDate = LocalDate.now(); LocalDate endDate = LocalDate.of(2020,12,01); System.out.println("---- StartDate : ---"+startDate); System.out.println("-----End Date : ----"+endDate); repository.save(new Person("Mehraj","Malik", startDate, endDate)); Output on Console : ---- StartDate : ---2017-08-26 -----End Date : ----2020-12-01 But In MongoDb it is