Unleash Your Potential - Namagunga Girls Coding Club
Global Mutable State Analysis in Spring MVC Applications
1. Global Mutable State
Analysis in Spring MVC
Applications
Formal Methods @ UCF
John L. Singleton
University of Central Florida
2. The Problem: Global Mutable State
• Web applications make extensive use of a form of Global
Mutable State called “session.”
• The behavior of session closely resembles global variables,
which are widely considered a form of code smell.
• But more importantly, the use of global variables increase
module coupling.
Formal Methods @ UCF
3. Goal: Investigate Use of Global Mutable
State in Spring-Based Web Applications
• Test Hypothesis:
“The use of global mutable state leads to tighter coupling and
therefore results in lower program reliability.”
• Static Analysis Question:
Which program executions may be influenced by the modification
of a given GMS variable.
Formal Methods @ UCF
4. Approach: Static Analysis of SpringBased Web Applications
• Since Verily already has support for static checking, the tool
was built within Verily.
• Verily internally leverages ANTLR to handle parsing and AST
building.
• Build data sets for finding problematic uses of GMS and making
specific recommendations about use of GMS in web
applications.
Formal Methods @ UCF
5. Analysis Method
Our tool performed 4 types of graph analysis:
•
•
•
•
Module
Variable
Behavior (read/write >=0)
Behavior (read/write > 0 – must use the value)
Additionally, we generated plot data for computing metrics we
define in this presentation.
6. Module Example
• Large Squares represent modules.
• “Points” represent use of a single GMS
variable.
• Multiple arrows leaving a point implies
multiple usages within a module.
• Arrows point to module in which the variable
is modified
Formal Methods @ UCF
Shared Issues Application
7. Variable Example
• Variable analysis gives more specific
information about the use of variables.
• Line number, module, etc.
• Useful for interpreting the other two types of
behavior analysis.
• These networks are huge and hard to
display in slides.
ELTabique Application
Formal Methods @ UCF
8. Behavior Example (with single writes)
• Behavior analysis makes it easy to visualize
application GMS behavior.
• Possible to quickly classify the type of
behavior being used for a specific GMS
variable.
• With writes shows variables that are only
written to but never read.
NCLodger Application
Formal Methods @ UCF
9. Behavior Example (w/o single writes)
• Same type of analysis as other type of
Behavior analysis.
• Excludes GMS variables that are written to
but never used again.
MivProject Application
Formal Methods @ UCF
11. Network Classification
Analysis revealed several different
types of networks.
• These networks appear to recur
in application designs.
• Each subnetwork represents the
behavior over a GMS variable.
Formal Methods @ UCF
12. Type 1: Ideal GMS Usage
• The ideal usage of GMS
is such that there exists
exactly one universal
sink in a subgraph.
• Lowest amount of cross
module coupling.
• (Verily’s GMS recipe
enforces this check)
Formal Methods @ UCF
13. Type 2: Less Ideal GMS Usage
• This type of network has
multiple sinks and
multiple reads within the
network.
• Multiple Reads, Multiple
Writes
Formal Methods @ UCF
14. Type 3: Least Ideal GMS Usage
• This type of network has
many different write
operations compared to
the number of reads.
• This results in the
highest form of coupling
since it crosses the most
number of modules.
• High Writes, Low Reads
Formal Methods @ UCF
15. Quantifying GMS Use
We define two sets for analyzing these networks:
Formal Methods @ UCF
16. Quantifying GMS Use: GMC
We then calculate Global Mutable Coupling as a measure of
GMS use:
Formal Methods @ UCF
18. Example: The Ideal Case
• For both networks, GMC = 1 and are therefore
ideal.
• Note that we don’t consider more “readers” to
increase the value of GMC.
Formal Methods @ UCF
19. Example: Less Ideal Cases
• GMC = 16, which shows a high degree of
coupling impact.
• Modifications in 4 different program points
influence the network in two difference places.
Formal Methods @ UCF
20. Example: Less Ideal Cases
• GMC = 49, which shows a very high degree of
coupling impact.
• This application is coupled across 7 possible
modules.
Formal Methods @ UCF
22. Source Data
To inform our analysis, we randomly pulled projects off of Github that made use
of Spring MVC and Global Mutable State
There are approximately 184,000 such projects available for analysis.
Our analysis was based on the following projects:
•
•
•
•
•
MivProject
TwitterApp
SharedIssues
NCLodger
EITabique
Formal Methods @ UCF
31. Thank You
• To learn more about Verily:
• http://goverily.org
• More about Formal Methods @ UCF:
• http://www.eecs.ucf.edu/~leavens/formal-methods-lab/
Formal Methods @ UCF