Quantcast
Channel: User Jonathan - Stack Overflow
Browsing latest articles
Browse All 40 View Live
↧

Comment by Jonathan on How to unit test java multiple thread

@stalet Yep, failed assertions or waiter.resume() calls will interrupt the awaiting main thread immediately. If a failure occurred, it will be re-thrown automatically allowing the test to fail as...

View Article


Comment by Jonathan on Retry Task Framework

More specifically, if you use, and want a dependency on, Spring Batch.

View Article


Comment by Jonathan on RabbitMQ - surviving a consumer disconnection using...

@JohnSmith Last I checked, only connection errors trigger recovery. Also rabbitmq.com/api-guide.html#cache-pitfalls

View Article

Comment by Jonathan on Async test wihout Thread.sleep

Two tools that might be helpful - Awaitility and ConcurrentUnit.

View Article

Comment by Jonathan on Junit, testing timer.schedule without relying on...

If you need to perform assertions from a Timer or ExecutorService thread, check out ConcurrentUnit.

View Article


Comment by Jonathan on Using Modelmapper, how do I map to a class with no...

You can also use a Provider to instantiate your destination class.

View Article

Comment by Jonathan on How to convert hex string to Java string?

Lots of substrings being created. Not ideal.

View Article

Comment by Jonathan on Styling for option values in a HTML select drop-down...

No luck on OSX with Chrome.

View Article


Comment by Jonathan on Intellij IDEA Java classes not auto compiling on save

Getting used to something that one IDE does for me and another does not, making my life more difficult, is not a good selling point.

View Article


Comment by Jonathan on How can I set highlight quote key color in yaml in...

@once I noticed the same thing as you - that vs code sees quoted keys as quoted strings rather than keys. Did you end up finding a solution?

View Article

Comment by Jonathan on Singleton pattern with Go generics

The problem of course is that the part of some code where a singleton is needed, such as in a separate library, isn't aware of the concrete value of T.

View Article

Comment by Jonathan on Singleton pattern with Go generics

Thanks for sharing this. Unfortunately it doesn't get around the problem posed above, where the singleton stored globally doesn't know what type argument might be supplied to it elsewhere. In your...

View Article

Answer by Jonathan for cannot select Parameterized Type

You can only learn the value of I and R by capturing them in a subclass definition - otherwise they are erased at runtime. Ex:class MyStringRestHelper extends RestHelper<String, String> {Then...

View Article


Answer by Jonathan for junit assert in thread throws exception

Where multiple worker threads are concerned, such as in the original question, simply joining one of them is not sufficient. Ideally, you'll want to wait for all worker threads to complete while still...

View Article

Answer by Jonathan for How do I write a JUnit test case to test threads and...

This is what I created ConcurrentUnit for. The general usage is:Spawn some threadsHave the main thread wait or sleepPerform assertions from within the worker threads (which via ConcurrentUnit, are...

View Article


Answer by Jonathan for Automapper for Java

Check out my ModelMapper. It was inspired by AutoMapper, but adds a few new things such as intelligent mapping.ModelMapper is an intelligent objectmapping framework that eliminates theneed to manually...

View Article

Answer by Jonathan for any tool for java object to object mapping?

My ModelMapper is another library worth checking out. ModelMapper's design is different from other libraries in that it:Automatically maps object models by intelligently matching source and destination...

View Article


Answer by Jonathan for DTO and mapper generation from Domain Objects

Consider checking out my ModelMapper.It differs from Dozer and others in that it minimizes the amount of configuration needed by intelligently mapping object models. Where configuration is needed,...

View Article

Answer by Jonathan for Framework for converting java objects

You might check out my ModelMapper.It differs from Dozer and others in that it minimizes the amount of configuration needed by intelligently mapping object models. Where configuration is needed,...

View Article

Answer by Jonathan for How to map POJO in to DTO, if fields are with...

My ModelMapper is another library worth checking out. It offers a fluent API to map properties as opposed to using string references or XML.Check out the ModelMapper site for more...

View Article

Answer by Jonathan for BeanUtils.copyProperties() vs DozerBeanMapper.map()

You might check out my ModelMapper. It will intelligently map properties (fields/methods) even if the names are not exactly the same. Defining specific properties to be mapped or skipped is simple and...

View Article


Answer by Jonathan for Designing a Guava LoadingCache with variable entry expiry

Another alternative is my ExpiringMap (I'm the author), which supports variable entry expiration:Map<String, String> map = ExpiringMap.builder().variableExpiration().build();map.put("foo", "bar",...

View Article


Answer by Jonathan for What's the design pattern for object to object...

The related pattern is Assembler where you assemble some object given the contents of another. Since writing assemblers can be tedious and error-prone, you can use an object mapping library to do the...

View Article

Answer by Jonathan for Retrieve generic type information with reflection

The only way this is workable is if you subclass StringObjectKeyValueStore:class FriendStore extends StringObjectKeyValueStore<Friend>{}The you can resolve V for a particular type, such as...

View Article

Answer by Jonathan for How to determine generic parameter of one of...

This is straightforward using TypeTools (which I authored):Class<?> typeArg = TypeResolver.resolveRawArgument(MyClass2.class, MyClass1.class);assert typeArg == MyClass3.class;

View Article


Answer by Jonathan for Create instance of generic type in Java?

Here's an implementation of createContents that uses TypeTools (which I authored) to resolve the raw class represented by E:E createContents() throws Exception { return...

View Article

Answer by Jonathan for Get actual type of generic type argument on abstract...

You might check out TypeTools (which I authored) for this:Class<T> t = (Class<T>)TypeResolver.resolveRawArgument(BaseDao.class, getClass());

View Article

Answer by Jonathan for Handling connection failures in apache-camel

For automatic RabbitMQ resource recovery (Connections/Channels/Consumers/Queues/Exchanages/Bindings) when failures occur, check out Lyra (which I authored). Example usage:Config config = new Config()...

View Article

Answer by Jonathan for Create instance of generic type in Java when...

What you're trying to do can work so long as E is parameterized in a type definition somewhere. For example:Parameterized<E> pe = new Parameterized<E>();This will not allow you to resolve E...

View Article



Answer by Jonathan for Spring dependency injection generic service class

Having a deep hierarchy you'll need to use something like TypeTools (which I authored):class DeviceDao extends BaseDao<Device> {}Class<?> entityType =...

View Article

Answer by Jonathan for How to verify the (generic (generic argument))?

Check out TypeTools (which I authored) for this. Example:List<String> stringList = new ArrayList<String>() {};Class<?> stringType = TypeResolver.resolveRawArgument(List.class,...

View Article

Answer by Jonathan for How to simplify retry code block with java 8 features

Using Failsafe (which I authored):RetryPolicy retryPolicy = new RetryPolicy() .retryOn(ExecutionException.class) .withMaxRetries(3);Failsafe.with(retryPolicy) .onRetry(r -> LOG.debug("retrying..."))...

View Article

Answer by Jonathan for Circuit breaker design pattern implementation

For a simple, straightforward circuit breaker implementation, check out Failsafe (which I authored). Ex:CircuitBreaker breaker = new CircuitBreaker() .withFailureThreshold(5) .withSuccessThreshold(3)...

View Article


Answer by Jonathan for Retry Task Framework

Check out Failsafe (which I authored). It's a simple, zero-dependency library for performing retries, and supports synchronous and asynchronous retries, Java 8 integration, event listeners, integration...

View Article

Answer by Jonathan for How to check does interface with generic fit to class

You can use something like TypeTools (a library that I authored) to resolve type arguments so long as the argument is captured in a type definition. For example:interface DummyStringInterface extends...

View Article

Answer by Jonathan for How to get generic type "T" of class when reused in...

If you are using my TypeTools library, this becomes pretty simple:Class<?> t = TypeResolver.resolveRawArgument(Parent.class, Child.class);

View Article


Answer by Jonathan for JUnit terminates child threads

The basic technique that Eyal Schneider outlined in his answer is what my ConcurrentUnit library is intended to accomplish. The general usage is:Spawn some threadsHave the main thread wait or...

View Article


Answer by Jonathan for Singleton pattern with Go generics

I ended up solving this using the atomic.Pointer API, and rolled it into a simple library for others to use if they're interested: singlet. Re-working the original post with singlet looks like...

View Article

Best way to link to another package in doc.go files

What's the best way to link to a doc in another package when writing package docs in a doc.go file? Unfortunately, the normal approach of referencing an imported package doesn't work in doc.go files...

View Article

Answer by Jonathan for Listing each branch and its last revision's date in Git

Here's a variation that sorts by date and puts the branch name before the date, which I find more readable:git branch -v --sort='-authordate:iso8601'...

View Article
Browsing latest articles
Browse All 40 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>