Generic return type upper bound

My question is an extension of this post. My question is relative to returning a generic List: the type of the returned list in the provided example works but why ? If I have a method like this: public static <E extends CharSequence, T extends ...
more »

2017-06-21 22:06 (0) Answers

Java: Cancel REST service method execution

I expose an Stateless EJB as a REST service. In my POST-method, I call Result r = longRunningBusinessMethod(); //return data How do I go about making it possible to cancel the execution of longRunningBusinessMethod() from the client side? I thoug...
more »

2017-06-21 20:06 (2) Answers

Get a PrivateKey from a RSA .pem file

Given this .pem file (generated with openssl and encrypted with a password): -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,AC009672952033EB 2wegzxf3MtncXS1CY3c..... .... .... -----END RSA PRIVATE KEY----- How do I ...
more »

2017-06-21 18:06 (2) Answers

Sorting nodes under two conditions?

only just started learning java and was stuck on this problem. Let's say I have a list of employees (I'll use only three of this examples) in no particular order and I go through the list and create a sorted link of nodes that all contain a name and ...
more »

2017-06-21 17:06 (0) Answers

Sort by date the column in datatable

I'm using jsf2.2 primefaces 6.0 and i'm trying to sort the datatable column by date as presented in the figure: I used sortBy" attribute in order to sort the date column but nothing happend. If there is a working solution on primefaces component "...
more »

2017-06-21 14:06 (2) Answers

RxJava2 Observable backpressure

recently I realized that I don't understand how RxJava2 backpressure works. I made small test and I expect that it should fail with MissingBackpressureException exception: @Test public void testBackpressureWillFail() { Observable.<Integer>...
more »

2017-06-21 12:06 (1) Answers

IdentityHashMap returning incorrect value

To my understanding, the following code should print false as it is doing identity based comparison. However, when I run the following code it is printing true: public class Test1 { public static void main(String[] args) { IdentityHashMap m...
more »

2017-06-21 11:06 (2) Answers

Filtering logs with regex in java

The description is quite long, so please bear with me: I have log files ranging from 300 mb to 1.5 Gb in size, which need to be filtered given a search key. The format of the logs is something like this: 24 May 2017 17:00:06,827 [INFO] 123456 (B...
more »

2017-06-21 10:06 (2) Answers

Using a variable inside Timer

I'm working on a program that has a prints time only when a function is called. I'm using timer for the continuous adding of seconds. Timer gameTimer = new Timer (); TimerTask time = new TimerTask() { int sec = 0; publi...
more »

2017-06-21 09:06 (2) Answers

Implementation of the Factory Design Pattern

I am developing a small application for my client and I tried to apply there Factory Method design pattern. I am not sure if I have done it correctly. Basically I have an abstract class Scheme that is extended by concrete Schemes (AccountScheme, Co...
more »

2017-06-21 02:06 (1) Answers

Reference to "parent" object

Let's assume i have two classes which look like this: public class Human { private String name; private String id; private List<Bike> bikes; } public class Bike { private String model; private String id; private Str...
more »

2017-06-21 01:06 (3) Answers

AWS ElastiCache connectivity issue in Spring Boot

Trying to configure AWS ElastiCache (memcached) but it doesn't connect to the cache cluster. There is no error as well, just it doesn't put data in the cache. Any pointers will help. Here is the code, I have just one file in my application for cach...
more »

2017-06-20 23:06 (0) Answers

Why does java stream.count() return a long?

Why doesn't a stream.count() return an int? I understand that I can easily convert the long to an int by casting, return (int); but why would a java stream.count() return a long instead of an int?...
more »

2017-06-20 21:06 (2) Answers

Akka stream sort by id in java

I need to sort my akka stream list by id in java I have list of objects in akka source: SystemCodeTracking{id=9, EntityName='table3'} SystemCodeTracking{id=2, EntityName='table2'} SystemCodeTracking{id=10, EntityName='table1'} I need to sort it to...
more »

2017-06-20 16:06 (1) Answers

Is it good practice to use ordinal of enum?

I have enum: public enum Persons { CHILD, PARENT, GRANDPARENT; } Is there any problem with using ordinal() method to check "hierarchy" between enum members? I mean - is there any disadvantages when using it excluding verbosity, when ...
more »

2017-06-20 15:06 (7) Answers

Finish n jobs in d steps by backtracking

I have several groups of tasks, each group is a chain of tasks, groups are independent of each other. Tasks within a group can only be processed in the order which is determined by the chain of that group. Each task has an ID and a cost. Tasks are ...
more »

2017-06-20 14:06 (1) Answers

Including REST-generated RSS feed

I've some problems to understand the functionality of RSS in my special situation. I've a REST service (written in Java using Spring) which reads some information from a database and dynamically generates the RSS page. The pubdate element of each ite...
more »

2017-06-20 14:06 (1) Answers