DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

The Latest Testing, Deployment, and Maintenance Topics

article thumbnail
Technical Spikes in DevOps
The true technical spike is a last resort and happens as infrequently as possible. It is a refinement activity that allows the backlog to be understood for future planning.
December 12, 2016
by $$anonymous$$
· 13,899 Views · 1 Like
article thumbnail
Node.js Performance Showdown
Let's pit different frameworks against each other and see who comes out on top.
December 12, 2016
by Alex Ogier
· 12,773 Views · 2 Likes
article thumbnail
Mastering the Couchbase N1QL Shell: Connection Management and Security
Couchbase's cbq shell lets you write and run N1QL queries interactively. The shell also lets you securely interact with mixed nodes, among other handy tricks.
December 9, 2016
by Isha Kandaswamy
· 8,659 Views · 5 Likes
article thumbnail
The Future of Continuous Testing
The smaller the device, the more complex the device build. This yields more value in testing concepts and procedures.
December 9, 2016
by Francis Adanza
· 8,397 Views · 1 Like
article thumbnail
How to Test HTTP Clients Using the Spark Micro-Framework
Spinning up heavyweight web or application servers adds complexity and slows tests down, but using the Spark micro-framework can make things easier and speed things up.
December 9, 2016
by Scott Leberknight
· 11,673 Views · 1 Like
article thumbnail
ConcurrentHashMap isn't always enough
When Java developers come to a task of writing a a new class which should have a Map datastructure field, accessed simultaneously by several threads, they usually try to solve the synchronization issues invloved in such a scenario by simply making the map an instance of ConcurrentHashMap . public class Foo { private Map theMap = new ConcurrentHashMap<>(); // the rest of the class goes here... } In many cases it works fine just because the contract of ConcurrentHashMap takes care of the potential synchronization issues related to reading/writing to the map. But there are cases where it's not enough, and a developer gets race conditions which are hard to predict, and even harder to find/debug and fix. Let's have a look, at the next example: public class Foo { private Map theMap = new ConcurrentHashMap<>(); public Object getOrCreate(String key) { Object value = theMap.get(key); if (value == null) { value = new Object(); theMap.put(key, value); } return value; } } Here we have a "simple" getter ( getOrCreate(String key) ), which gets a key and returns the value assosiated with the given key in theMap . If there is no mapping for the key, the method creates a new value, inserts it into theMap and returns it. So far so good. But what happens when 2 (or more) threads call the getter with the same key when there is no mapping for the key in theMap? In such a case we might receive a race condition: Suppose thread t1 enters the function and comes to line 7. Its value is null . At this point thread t2 enters the function and also comes to line 7. Its value is also obviously null . Therefore from this point the two threads will enter the if statement and execute lines 8 and 9, thus creating two different new Objects. Upon returning from the getter each thread will get a different Object instance, violating programmer's wrong assumption that by using ConcurrentHashMap "everything is synchronized" and therefore two different threads should get the same value for the same key. To solve this issue we can synchronize the entire method, thus making it atomic: public class Foo { private Map theMap = new ConcurrentHashMap<>(); public synchronized Object getOrCreate(String key) { Object value = theMap.get(key); if (value == null) { value = new Object(); theMap.put(key, value); } return value; } } But this is a bit ugly, and uses Foo instace's monitor, which may affect performance if there are other methods in this class which are synchronized. Also a common rule of thumb is to try to eliminate using synchronized methods as much as possible. A much better approach should be using Java 8 Map's computeIfAbsent(K key, Function mappingFunction), which, in ConcurrentHashMap's implementation runs atomically: public class Foo { private Map theMap = new ConcurrentHashMap<>(); public Object getOrCreate(String key) { return theMap.computeIfAbsent(key, k -> new Object()); } } The atomicity of computeIfAbsent(..) assures that only one new Object will be created and put into theMap, and it'll be the exact same instance of Object that will be returned to all threads calling the getOrCreate function. Here, not only the code is correct, it's also cleaner and much shorter. The point of this example was to introduce a common pitfall of blindly relying on ConcurrentHashMap as a majical synchronzed datastructure which is threadsafe and therefore should solve all our concurrency issues regarding multiple threads working on a shared Map. ConcurrentHashMap is, indeed, threadsafe. But it only means that all read/write operations on such map are internally synchronized. And sometimes it's just not enough for our concurrent environment needs, and we have to use some special treatment which will guarantee atomic execution. A good practice will be to use one of the atomic methods implemented by ConcurrentHashMap, i.e: computeIfAbsent(..), putIfAbsent(..), etc.
December 8, 2016
by Dima Leah
· 48,747 Views · 12 Likes
article thumbnail
Creating Maps With Named Lambdas
Learn how you can create a Java Map like this: map = mapOf(one -> 1, two -> 2) using a trick to get the lambda parameter name.
December 7, 2016
by Per-Åke Minborg
· 23,502 Views · 49 Likes
article thumbnail
Antipattern of the Month: Cherry Picking
The best DevOps teams exhibit a high level of cross-skilling, and cherry-picking often occurs in teams in which the members are not cross-trained. Read on to learn more.
December 7, 2016
by $$anonymous$$
· 10,076 Views · 4 Likes
article thumbnail
How to Compose an Infinispan Docker Image
Read on to explore how to create multicontainer Docker applications involving Infinispan with the help of Docker Compose.
December 7, 2016
by Manik Surtani
· 7,329 Views · 3 Likes
article thumbnail
Top 5 Factors That Impact Your Software Performance
Knowing where your software is failing is essential to identifying the bottleneck. These five performance-impacting factors give you a good place to start.
December 7, 2016
by Thamwika Bergstrom
· 6,928 Views · 3 Likes
article thumbnail
How to Use Compare and Merge for SwaggerHub
Read on to find out how to keep API documentation shipping moving forward smoothly by using Compare and Merge for SwaggerHub.
December 7, 2016
by Keshav Vasudevan
· 8,078 Views · 4 Likes
article thumbnail
An Introduction to JBehave and BDD
Want to avoid a glassy-eyed stare you get when trying to explain your code to stakeholders? Check out how JBehave and behavior-driven development can help.
December 7, 2016
by Arun Pandey DZone Core CORE
· 55,993 Views · 14 Likes
article thumbnail
Android Fingerprint Authentication Tutorial
In this post we take a look at an example of how to make use of Android's built-in fingerprint authentication APIs. Read on to find out more!
December 6, 2016
by Francesco Azzola
· 29,857 Views · 6 Likes
article thumbnail
Keeping Submodules Up to Date in Git
When your project gets complicated, it makes sense to split it up into manageable chunks. Git supports this process using submodules.
December 5, 2016
by Tim Myerscough
· 9,499 Views · 2 Likes
article thumbnail
Software-Defined Integration: A New Trend or Just a Fancy Name?
Software-defined everything seems to be everywhere these days. In this article, Olga Annenko discusses software-defined integration and what it should mean to you.
December 5, 2016
by Olga Annenko
· 7,490 Views · 2 Likes
article thumbnail
Predictions for DevOps in 2017
Security, containers, as-a-service, and enterprise-wide adoption.
December 2, 2016
by Tom Smith DZone Core CORE
· 11,004 Views · 4 Likes
article thumbnail
A Review of Java Template Engines
In this article, Miro Kopecky provides a thorough review of Java template engines Apache Velocity, Apache FreeMarker, Thymeleaf, and Pebble.
December 2, 2016
by Miro Wengner
· 86,965 Views · 12 Likes
article thumbnail
How Can You Use ChefSpec to Unit Test Chef Cookbooks?
Learn how to set up a workstation to run Chef locally and use the existing Chef community cookbook to deploy the application on the local workstation environment.
November 30, 2016
by Greg Sypolt
· 6,043 Views
article thumbnail
Camel and Kura: Providing Telemetry Data as OPC UA
If you're using an industrial M2M protocol, consider the combined power of Camel and Kura to get your telemetry data squared away as OPC UA.
November 29, 2016
by Jens Reimann
· 6,037 Views · 3 Likes
article thumbnail
Testing a Node.JS Application Within a Docker Container
Learn how to take advantage of the Docker image layering model to run unit or component tests in a Docker container without polluting the production software.
November 29, 2016
by Nahshon Una-Tsameret
· 57,395 Views · 8 Likes
  • Previous
  • ...
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×