Open in app

Sign in

Write

Sign in

辰
辰

26 Followers

Home

About

Jun 22, 2021

Allowing an Insecure Protocol for accessing repository via HTTP

Recently, Gradle started complaining about an insecure protocol for my maven repositories configured in build.gradle. repositories { mavenCentral() maven { url "http://nexus..." } } I realized that I can’t change the protocol of the server and I put allowInsecureProtocol true to the configuration. repositories { mavenCentral() maven { url "http://nexus..." allowInsecureProtocol true } }

Gradle

1 min read

Gradle

1 min read


Mar 7, 2021

Using a generic wrapper class for marshalling/unmarshalling with JAXB

This is an in-action case of Creating a Generic List Wrapper in JAXB. The Wrapper class is final, its no-args constructor is private and even the factory method is private. public final Wrapper<T> { private static <T> of(final List<T> elements) { Objects.requireNonNull(elements); final Wrapper<T> instance = new Wrapper<>(); instance.elements …

Java

2 min read

Java

2 min read


Jun 29, 2020

AttributeConverter for TemporalAccessors and Strings

I’ve encountered, quite a few times, into situations that I need to convert database strings into LocalDateTime instances. Let’s write an abstract class for that. abstract class TemporalAccessorStringConverter< T extends TemporalAccessor> implements AttributeConverter<T, String> { } Two constructors are added. protected TemporalAccessorConverter( final…

Java

2 min read

Java

2 min read


May 20, 2020

Effective Java, 3rd, Distilled

Distilled as short as possible — Links for Books Effective Java 3rd Edition 이펙티브 자바 제3판 Foreword Preface Acknowledgments 1 Introduction 2 Creating and Destroying Objects Item 1: Consider static factory methods instead of constructors Item 2: Consider a builder when faced with many constructor parameters Item 3: Enforce the singleton property with a private constructor or an enum type Item 4: Enforce noninstantiability with a private constructor

Java

4 min read

Java

4 min read


Apr 17, 2020

Accessing fields with MethodHandles

Recently I had to define some utility methods for accessing fields with their names. The basic utility method that following codes based is ReflectionUtils#findField(Class<?>, String). Let’s create a cache for (already found) fields for increasing re-usability. private static Map<Class<?>, Map<String, Field>> FIELDS = synchronizedMap(new WeakHashMap<>()); And here comes the method…

Java

2 min read

Java

2 min read


Oct 26, 2019

An anti-pattern for try-with-resources

I just found my own anti-pattern regarding the try-with-resources statements. Whenever I encountered code like this. try (InputStream is = getSome()) { } The kind IDE tells me that I need to handle the IOException which is obviously from the close() method. And I instinctively add an outer try-catch block like this. try { try (InputStream is = getSome()) { } } catch (final IOException ioe) { ... }

Java

1 min read

Java

1 min read


Published in

Javarevisited

·Apr 25, 2019

How to check whether an Iterable is sorted or not in Java

java.lang.Iterable<T> The description of java.lang.Iterable<T> is fairly simple. Implementing this interface allows an object to be the target of the enhanced for statement (sometimes called the "for-each loop" statement). Simply, with given instance of Iterable<T>, we can do this. for (final T i : iterable) { // for-each element, as…

Programming

3 min read

How to check whether an Iterable is sorted or not
How to check whether an Iterable is sorted or not
Programming

3 min read


Published in

Javarevisited

·Apr 24, 2019

How to use Temporary files for Unit testing in Java

Sometimes we need to create temporary files and use them in a unit test. And usually, I do like this. @Test void testSome() { File file; try { file = File.createTempFile("tmp", null); } catch…

Java

3 min read

Using temporary files for unit testing
Using temporary files for unit testing
Java

3 min read


Published in

Javarevisited

·Mar 28, 2019

Avoid this wrong usage of a method reference in Java

Check this out. // returns an array of given length with random values. int[] randomArray(@Min(1) final int length) { return range(0, length).map(current()::nextInt).toArray(); } I, simply, shocked when I saw the following stack trace. java.lang.IllegalArgumentException: bound must be positive at java.base/java.util.concurrent.ThreadLocalRandom.nextInt(ThreadLocalRandom.java:310) ... So, what was wrong?

Java

1 min read

A case of a wrong method reference
A case of a wrong method reference
Java

1 min read


Published in

Javarevisited

·Mar 5, 2019

@lombok.Data and MyBatis

With my following result type, @Data public class Some { ... private List<Sting> keywords; } MyBatis with following ResultMap complains about creating results. <collection property="keywords" ofType="string" javaType="list"> <result column="keyword"/> </collection> That’s because @Data annotation works as @RequiredArgsConstructor , MyBatis couldn’t create the value. And that’s why I changed the class like this.

Java

1 min read

@lombok.Data and MyBatis
@lombok.Data and MyBatis
Java

1 min read

辰

辰

26 Followers

Just a Java programmer

Following
  • javinpaul

    javinpaul

  • Soma

    Soma

  • JinHyeong bak

    JinHyeong bak

  • Tim Berners-Lee

    Tim Berners-Lee

  • Varuna

    Varuna

See all (36)

Help

Status

About

Careers

Blog

Privacy

Terms

Text to speech

Teams