• Under the Hood of PVS-Studio for Java: How We Develop Diagnostics


      To keep it interesting, this time I'd like to tell about our approach to developing and polishing diagnostic rules for PVS-Studio Java. You will learn how we keep existing warnings consistent across releases and why the new ones aren't too weird. I'll also share a bit of inside information on what plans we, the Java team, have for the future, and show you a few interesting (and a few plain) bugs we found using the diagnostics from the upcoming release.
      Read more →
    • Spring transaction management. Isolation and propagation

        Introduction


        In my opinion transaction management is a really important topic for each backend developer. In general, people don’t pay attention to it while using Spring framework.


        But I think, it is important to know how to use transactions properly. Because sometimes can happen that there was an exception thrown inside your method, but transaction was not rolled back and it is not clear why? Or some other “strange” cases.

        Read more →
      • The Testcontainers’ MongoDB Module and Spring Data MongoDB Reactive in Action

        1. Introduction


        How can I easily test my MongoDB multi-document transaction code without setting up MongoDB on my device? One might argue that they have to set it up first because in order to carry out such a transaction it needs a session which requires a replica set. Thankfully, there is no need to create a 3-node replica set and we can run these transactions only against a single database instance.

        Read more →
      • IntelliJ IDEA: Structural Search and Replace

        • Translation
        • Tutorial

        Modern IDEs are very powerful tools that can help developers in all kinds of situations. Unfortunately, much of this power is often lost because many functions remain unknown to developers, hiding in the shadows.


        Simple example of the one of the such functions

        Did you know that when you press F2 in IntelliJ IDEA, the cursor will jump to the nearest error in the file? And in the absence of an error – to the nearest warning? It seems that this is a secret only a few people know about.


        Structural search and replace is one such pair of features. They can be extremely useful in situations where a whole variety of other functions can’t quite get the job done.


        In this post, I will present some of these situations and go beyond artificial cases by demonstrating examples of real code from two projects:


        1. 3D-engine for game development, jMonkeyEngine, which is an example of a big, interesting project.
        2. My own pet project, plantuml-native-image, where I experiment with compiling PlantUML into native executable code using GraalVM Native Image.

        In fact, it is this second project that encouraged me to write this post but I’m getting ahead of myself. First things first...

        Read more →
      • Small things that pollute your code

          I'm not going to discuss global things like design patterns and so on, as there's enough literature on that topic. Instead, I'd like to attract your attention to some small things that still affect lucidity and maintainability of a code.

          Polluting code with 'test-only' methods or access modifiers


          First of all, if you give access to something that shouldn't be used in production code, it gets used sooner or later. Just because it exist. The argument that it's an internal stuff doesn't work as it absolutely shouldn't be matter, writing you a library or isolated project! Treat people who will add anything to your internal codebase the same way as if they use your existing code as a different library.

          Thus, if for some reason in test, you need to call something that should not be called on prod — use reflection or whatever else but do not expose it in production code! And there's no reason to afraid of reflection for test proposes, at the end, you using Mockito, shouldn't it be bad in that case as well?
          Read more →
        • The PVS-Studio analyzer: detecting potential compatibility issues with Java SE API

            Рисунок 9

            2019 was a very busy year in terms of conferences. Our team could leave for whole weeks on business trips. As you know, the conference is perfect time to share knowledge. In addition to giving talks and telling many interesting things at our booth, we also learned a lot from communicating with conference participants and speakers. So at the Joker 2019 conference in fall, a talk from Dalia Abo Sheasha «Migrating beyond Java 8» inspired us to implement a new diagnostic rule that allows us to detect incompatibilities in the Java SE API between different versions of Java. This is what we will talk about.
            Read more →
          • Java vs .Net: Who will Reign in the Future?

            As the time is changing, technologies are expanding and with that, the priority and the importance of the technical languages are also changing. So, usually, it becomes difficult to pick when we have to choose between two languages.

             

             

            java vs .net


             

            Here we will see the battle between Java and Microsoft .Net in order to make this clear which language is better to choose. For that, you may also have a quick look at this short video:
            Read more →
          • AdBlock has stolen the banner, but banners are not teeth — they will be back

            More
            Ads
          • NSA, Ghidra, and Unicorns

              NSA, Ghidra, and Unicorns

              This time, the PVS-Studio team's attention was attracted by Ghidra, a big bad reverse-engineering framework allowing developers to analyze binary files and do horrible things to them. The most remarkable fact about it is not even that it's free and easily extensible with plugins but that it was developed and uploaded to GitHub for public access by NSA. On the one hand, you bet NSA has enough resources for keeping their code base clean. On the other hand, new contributors, who are not well familiar with it, may have accidentally introduced bugs that could stay unnoticed. So, we decided to feed the project to our static analyzer and see if it has any code issues.
              Read more →
            • Annotations for Concurrency in Java. Our approach to coloring threads

                At Miro, we always try to improve the maintainability of our code by using common practices, including in matters of multithreading. This does not solve all the issues that arise because of the ever-increasing load, but it simplifies the support: it increases both the code readability and the speed of developing new features.

                Today (May 2020) we have about 100 servers in the production environment, 6,000 HTTP API requests per second and more than 50,000 WebSocket API commands, and daily releases. Miro has been developing since 2011; in the current implementation, user requests are handled in parallel by a cluster of different servers.

                image
                Read more →
              • Traps and pitfalls in modernization of enterprise application using «supersonic subatomic java»

                This is a post about first steps and first pitfalls in modernization of old enterprise application using "supersonic subatomic java" quarkus as it is positioned by RedHat.


                Initial setup


                In the end of 2019 I was invited to work in a project in our company, where an old monolithic application should be split into micro-services. Basic reasoning behind this decision was, that framework which is used in application is near to it's end-of-life. The application should be rewritten in any case. If it should be rewritten in any case, why not to split it into micro-services?


                Since last 10 years, I was working mostly with java and we had in the project specialists with java knowledge, we have decided to give java-based frameworks a try for back-end functionality.
                OK, let's use spring-cloud for that purpose, was our first thought. But then, we have had a look onto quarkus, which has been released in the end of 2019. We have decided to give it a try, keeping in mind building of native applications using GraalVM.


                Native applications from our perspective could give us following benefits:


                • shorten start time of container
                • reduce resource consumption of container and application

                We were aware about possible drawbacks of this solution:


                • no experience in our team with quarkus framework
                • significantly less amount of available feedback from community, since this is very young framework
                Read more →
              • Discover Unmatched Potential of Java for Your Next App



                  One of the most popular programming languages for a decade, Java has been the top choice and preference of most software application development companies. More and more businesses are looking forward to leveraging the potential of the Java language. How can they not? The websites, web apps, mobile apps all could be developed easily using the language. From small, easy to complex apps, Java is the best-suited as it is robust, reliable, and user-friendly programming language.
                  Read more →
                • Zero, one, two, Freddy's coming for you

                    Рисунок 1

                    This post continues the series of articles, which can well be called «horrors for developers». This time it will also touch upon a typical pattern of typos related to the usage of numbers 0, 1, 2. The language you're writing in doesn't really matter: it can be C, C++, C#, or Java. If you're using constants 0, 1, 2 or variables' names contain these numbers, most likely, Freddie will come to visit you at night. Go on, read and don't say we didn't warn you.
                    Read more →
                  • Introducing One Ring — an open-source pipeline for all your Spark applications

                      If you utilize Apache Spark, you probably have a few applications that consume some data from external sources and produce some intermediate result, that is about to be consumed by some applications further down the processing chain, and so on until you get a final result.


                      We suspect that because we have a similar pipeline with lots of processes like this one:


                      A process flowchart with more than 50 applications and about 70 datasets
                      Click here for a bit larger version


                      Each rectangle is a Spark application with a set of their own execution parameters, and each arrow is an equally parametrized dataset (externally stored highlighted with a color; note the number of intermediate ones). This example is not the most complex of our processes, it’s fairly a simple one. And we don’t assemble such workflows manually, we generate them from Process Templates (outlined as groups on this flowchart).


                      So here comes the One Ring, a Spark pipelining framework with very robust configuration abilities, which makes it easier to compose and execute a most complex Process as a single large Spark job.


                      And we just made it open source. Perhaps, you’re interested in the details.

                      We got you covered!
                    • Glean Insights About 18 Best Java Frameworks To Use in 2020

                        image


                        Who doesn’t know about Java today? You can hear its mention in every nook and corner of the world. A significant majority of IT companies provide Java-based applications, while businesses are still driven to secure java applications due to robustness and stringent security facilities. However, Java frameworks are a matter of chaos for a variety of business owners that want their application to be standout.


                        The fact is that there is no dearth of java frameworks that makes application development simple and efficient. However, a number of people have a query regarding the selection of java framework on the basis of features, ease-of-use, cost, and many more. Businesses hire programmers in India, though they stay confused on which platform they want their app to be created.

                        Read more →
                      • Introducing Java 13: Let's dive Into JDK's New Features



                          Java has been a programmer’s dream and what’s the better way to quantify Java’s popularity with the new version release Java 13. After the initial Java enhancement proposal, there have been advancements in JDK features that will blow up Java developer’s mind with a new range of features after the official release on September 17, 2019.

                          But Why do you think Java is so popular?

                          Java has been a craze among programmers due to its platform independence and the ability to run on different computers. It has been there for so long that it has been adopted by organizations like banks, insurance companies, enterprises, agencies and mostly by software outsourcing companies.

                          Java has been there in the business to develop android apps, java web applications, software tools, and scientific applications.

                          Let us delve into the stats and gauge the popularity ratio of Java applications among other competing programming languages.
                          Read more →
                        • Top programming languages for Android App development in 2020

                            Do you have any idea how many Android apps are there in the world? As of 2019’s first quarter, there were approximately 2.6 million android apps around the globe. That’s a huge number which leads to stiff competition in the market.

                            There is no other option other than offering a robust and efficient Android app to survive in this flourishing industry. The selection of the right tech-stack is highly important if you want to get a flawless development of your Android app.
                            Read more →
                          • Testing Water Melon using Neural Networks: Full Dev. Cycle from prototyping to the App. at Google Play

                            • Tutorial

                            The beginning


                            It all started when I found an app. on Apple market, that supposedly was able to determine the ripeness of a water mellon. A program was… strange. Just think about it: instead of knocking using your knuckles, you were supposed to hit the water mellon with your iPhone! Nevertheless, I have decided to repeate that functionality on an Andtoid platform.
                            Read more →
                          • Top 10 Bugs Found in Java Projects in 2019


                              2019 is drawing to an end, and the PVS-Studio team is looking back at the accomplishments of this year. In the beginning of 2019, we enhanced our analyzer's diagnostic capabilities by adding Java support, which enabled us to check and review Java projects as well. We have found lots of bugs over this year, and here's our Top 10 bugs found in Java projects.
                              Read more →
                            • Apache Hadoop Code Quality: Production VS Test

                                Рисунок 1

                                In order to get high quality production code, it's not enough just to ensure maximum coverage with tests. No doubts, great results require the main project code and tests to work efficiently together. Therefore, tests have to be paid as much attention as the main code. A decent test is a key success factor, as it will catch regression in production. Let's take a look at PVS-Studio static analyzer warnings to see the importance of the fact that errors in tests are no worse than the ones in production. Today's focus: Apache Hadoop.
                                Read more →
                              • Open Source Java library with stacktrace filtering, Silent String parsing and Version comparison

                                Over some time in different jobs, I came across a need for several utilities that I couldn't find available at the time. And I saw that I needed them several times over and over again. So I wrote my own small library that I found very useful. So I just published it as an open-source java library.

                                Here is the Github link

                                Javadoc online is available here

                                Also, this library is available on Maven Central. Here are the Maven artifacts (the version 1.5.1.0 is the latest at the time of writing of this article but might change in the future. To check for the latest version search for artifact «MgntUtils» at http://search.maven.org/):

                                <dependency>
                                     <groupId>com.github.michaelgantman</groupId>
                                     <artifactId>MgntUtils</artifactId>
                                     <version>1.5.1.0</version>
                                </dependency>
                                
                                 <dependency>
                                     <groupId>com.github.michaelgantman</groupId>
                                     <artifactId>MgntUtils</artifactId>
                                     <version>1.5.1.0</version>
                                     <classifier>javadoc</classifier>
                                </dependency>
                                
                                <dependency>
                                     <groupId>com.github.michaelgantman</groupId>
                                     <artifactId>MgntUtils</artifactId>
                                     <version>1.5.1.0</version>
                                     <classifier>sources</classifier>
                                </dependency>
                                

                                Below is just a short explanation of what is there. The library comes with a nicely written (I hope) JavaDoc with a detailed description. So here is the list of features:
                                Read more →